You are not logged in.

#1 2011-11-23 11:47:10

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

This is where Linphone is storing contacts

File: ~/.linphonerc

[sound]
playback_dev_id=ALSA: HDA Intel
ringer_dev_id=ALSA: default device
capture_dev_id=ALSA: HDA Intel
echocancellation=1
remote_ring=/usr/share/sounds/linphone/ringback.wav
local_ring=/usr/share/sounds/linphone/rings/oldphone.wav

[video]
size=cif
enabled=0
display=0
capture=0
show_local=0
self_view=0

[GtkUi]
advanced_ui=1
lang=C
videoselfview=0
uri0="****" <sip:****@ekiga.net>
uri1="****" <sip:****@ekiga.net>
uri2="Echo test (031600)" <sip:*031600@ekiga.net>
uri3=<sip:****@ekiga.net>
uri4="****" <sip:****@ekiga.net>
uri5="Echo Test (ekiga.net)" <sip:500@ekiga.net>

[call_log_0]
dir=0
status=0
from=<sip:****@ekiga.net>
to="****" <sip:****@ekiga.net>
start_date=Thu Nov 10 13:23:39 2011
duration=41

[call_log_1]
dir=0
status=0
from=<sip:****@ekiga.net>
to="****" <sip:****@sip.linphone.org>
start_date=Wed Nov  9 00:23:40 2011
duration=17

[net]
download_bw=0
upload_bw=0
firewall_policy=0
mtu=0

[sip]
sip_port=5059
guess_hostname=1
contact="****" <sip:****@LAN_IP:5059>
inc_timeout=15
use_info=0
use_rfc2833=0
use_ipv6=0
register_only_when_network_is_up=1
default_proxy=1
sip_tcp_port=0

[rtp]
audio_rtp_port=7078
video_rtp_port=9078
audio_jitt_comp=60
video_jitt_comp=60
nortp_timeout=30

[audio_codec_0]
mime=speex
rate=32000
enabled=1

[audio_codec_1]
mime=speex
rate=16000
enabled=1

[audio_codec_2]
mime=speex
rate=8000
enabled=1

[audio_codec_3]
mime=PCMU
rate=8000
enabled=1

[audio_codec_4]
mime=PCMA
rate=8000
enabled=1

[call_log_2]
dir=1
status=0
from=<sip:****@ekiga.net>
to=<sip:****@ekiga.net>
start_date=Wed Oct 19 09:06:23 2011
duration=76

[call_log_3]
dir=0
status=1
from=<sip:****@ekiga.net>
to=<sip:****@ekiga.net>
start_date=Wed Sep 28 00:17:10 2011
duration=44

[friend_0]
url="Echo test (010600)" <sip:*010600@ekiga.net>
pol=accept
subscribe=1

[friend_1]
url="4151595" <sip:4151595@services.sip.is>
pol=accept
subscribe=1

[friend_2]
url="1234" <sip:1234@loligo.com>
pol=accept
subscribe=1

[friend_3]
url="Echo Test (ekiga.net)" <sip:500@ekiga.net>
pol=accept
subscribe=1

[friend_4]
url="501xxxx" <sip:501xxxx@ekiga.net>
pol=deny
subscribe=1

[friend_5]
url="Echo test (850301)" <sip:*850301@ekiga.net>
pol=accept
subscribe=1

[friend_6]
url="Idea SIP's weird voice mail message" <sip:*850**12345@ekiga.net>
pol=accept
subscribe=1

[friend_7]
url="SipBroker Test announcement" <sip:*011188888@ekiga.net>
pol=accept
subscribe=1

[friend_8]
url="Echo test (031600)" <sip:*031600@ekiga.net>
pol=accept
subscribe=1

[proxy_0]
reg_proxy=sip:sip.linphone.org
reg_identity=sip:****@sip.linphone.org
reg_expires=3600
reg_sendregister=1
publish=1
dial_escape_plus=0

[proxy_1]
reg_proxy=sip:ekiga.net
reg_identity=sip:****@ekiga.net
reg_expires=3600
reg_sendregister=1
publish=1
dial_escape_plus=0

[auth_info_0]
username=****
userid=****
passwd=****
realm="ekiga.net"

[auth_info_1]
username=****
userid=****
passwd=****
realm="sip.linphone.org"

[auth_info_2]
username=****
userid=****
passwd=****
realm="sip2sip.info"

I want a pipe-menu which will manage these contacts above in the following order

#!/bin/bash
# Openbox Pipe Menu for xcompmgr
# Written for CrunchBang Linux <http://crunchbang.org/projects/linux/>
# by Philip Newborough (aka corenominal) <mail@philipnewborough.co.uk>

# Set xcompmgr command options
EXEC='linphonecsh init'

# Toggle compositing. Call with "myxcompmgr --startstop"
if [ "$1" = "--startstop" ]; then 
    if [ ! "$(pidof linphonec)" ]; then
      $EXEC
    else
      linphonecsh exit
    fi
    exit 0
fi
# Output Openbox menu
if [ ! "$(pidof linphonec)" ]; then
    cat << _EOF_
    <openbox_pipe_menu>
	    <item label="Start">
            <action name="Execute">
				<execute>
					linphonec-openbox --startstop
				</execute>
			</action>
		</item>
    </openbox_pipe_menu>
_EOF_
else
    cat << _EOF_
    <openbox_pipe_menu>
				<item label="Echo test (010600)">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:*010600@ekiga.net
						</execute>
					</action>
				</item>
				<item label="Dial 4151595">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:4151595@services.sip.is
						</execute>
					</action>
				</item>
				<item label="Dial 1234">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:1234@loligo.com
						</execute>
					</action>
				</item>
				<item label="Dial Echo Test (ekiga.net)">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:500@ekiga.net
						</execute>
					</action>
				</item>
				<item label="Dial 501xxxx">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:501xxxx@ekiga.net
						</execute>
					</action>
				</item>
				<item label="Echo test (850301)">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:*850301@ekiga.net
						</execute>
					</action>
				</item>
				<item label="Dial Idea SIP's weird voice mail message">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:*850**12345@ekiga.net
						</execute>
					</action>
				</item>
				<item label="Dial SipBroker Test announcement">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:*011188888@ekiga.net
						</execute>
					</action>
				</item>
				<item label="Dial SipBroker Test announcement">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:*011188888@ekiga.net
						</execute>
					</action>
				</item>
				<item label="Dial Echo test (031600)">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:*031600@ekiga.net
						</execute>
					</action>
				</item>
				<separator/>
				<item label="Quit">
					<action name="Execute">
						<execute>
							linphonec-openbox --startstop
						</execute>
					</action>
				</item>
    </openbox_pipe_menu>
_EOF_
fi
exit 0

linphonecsh  -  Sends  a command to a linphonec running in daemon mode, and exits
http://www.linphone.org/eng/documentati … ntrol.html

Offline

#2 2011-11-23 19:34:33

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

I'm not sure what you are asking for.

Are you asking how to configure openbox to use this script?

If so, then do the following from a terminal:

1) Place your script in and cd to ~/.config/openbox

2) Make it executable by doing
    $ chmod +x scriptname

3) Edit ~/.config/openbox/menu.xml to include the line (modify to suit your taste):
    <menu id="linphone-menu" label="Contacts" execute="~/.config/openbox/scriptname"/>

4) Again edit ~/.config/openbox/menu.xml so that the following line is somewhere in your "root-menu"
    <menu id="linphone-menu"/>

5) Tell openbox of your changes by doing
    $ openbox --reconfigure

Offline

#3 2011-11-24 03:45:43

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

No. I want a script that will generate a list of my Linphone contacts which are listed in the file ~/.linphonerc (each contact is located under a line with [friend_<NUMBER>])

Similarly to the Perl Script obpipemenu-places which is delivered with CrunchBang 9.04.01 and what it does is generating a menu from your Home directory which is simply allowing to you to browse your file system via the Openbox menu.

http://crunchbanglinux-fr.org/forum/vie … =419#p8513
http://crunchbanglinux.org/pastebin/193 … enu-places

Offline

#4 2011-11-24 05:31:35

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Try this script:

#!/bin/bash

grepstr='friend_[0-9]*'
cdata=$(grep -A 1 "$grepstr" ~/linphonerc)
labels=( $(grep -o "$grepstr" <<< "$cdata") )

cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<openbox_pipe_menu>
EOF

for m in "${labels[@]}"; do
	contact=$(grep -A 1 "$m" <<< "$cdata" | grep -o 'sip:.*[^>]')
	echo "  <item label=$m>"
	echo "    <action name=\"Execute\">"
	echo "      <execute>linphonecsh dial $contact</execute>"
	echo "    </action>"
	echo "  </item>"
done
echo '</openbox_pipe_menu>'

Last edited by rockin turtle (2011-11-24 05:34:20)

Offline

#5 2011-12-01 14:14:45

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

@rockin turtle
Thank you for the effort, and sorry for the late answer.
Unfortunately, it is not working.

Edit:
- Situation 1 http://x45.img-up.net/?up=1ob4cawq.png
- Situation 2 http://p16.img-up.net/?up=2obgfk3f.png

Last edited by RedArcher (2011-12-01 14:28:03)

Offline

#6 2011-12-02 04:27:22

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Part of the problem is that I've never used linphone, I don't know how it works, and I didn't read through all the links you provided before I posted my script.

The script you posted executes the command '$ linphonec-openbox --startstop'. Do you know if you have an executable file named 'linphonec-openbox' somewhere in your path?  I'm guessing that you have to execute this file to start the linphone daemon before you can call someone.  The script I posted does not do this.

Also, it appears to me that you modified the .linphonerc file before you posted it to change your friend's names and contact info.  If this is the case, the script I posted will not work.

Perhaps the following will work.

#!/bin/bash

contacts=$(while read line; do
	[[ "$line" =~ ^-- ]] && echo || echo -n "$line "
done < <(grep -B 1 url linphone))

cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<openbox_pipe_menu>
EOF

if pidof linphonec; then
	while read line; do
		label=$(grep -o '\[.*\]' <<< "$line")
		cmd=$(grep -o 'sip:[^>]*' <<< "$line")
		echo  "  <item label=\"$label\">"
		echo  '    <action name="Execute">'
		echo  "      <execute>linphonecsh dial $cmd</execute>"
		echo $'    </action>\n  </item>'
	done <<< "$contacts"
else
    cat << _EOF_
  <item label="Start">
    <action name="Execute">
      <execute>
        linphonec-openbox --startstop
      </execute>
    </action>
  </item>
_EOF_
fi

echo '</openbox_pipe_menu>'

Offline

#7 2011-12-02 06:59:23

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

The script is stored at ~/.config/openbox/obpipemenu/linphonec-openbox which has a shortcut to it at ~/bin/linphonec-openbox

I made this bin directory so that I'll have a directory to fiddle with custom commands before I am messing with the system directories, if at all.

~/.profile

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# add /usr/sbin/
if [ -d /usr/sbin/ ]; then
    PATH="/usr/sbin/:$PATH"
fi

# add /sbin
if [ -d /sbin ]; then
    PATH="/sbin:$PATH"
fi

# add /sbin games
#if [ -d /sbin ]; then
#    PATH="$PATH:/sbin"
#fi
rockin turtle wrote:

Also, it appears to me that you modified the .linphonerc file before you posted it to change your friend's names and contact info.  If this is the case, the script I posted will not work.

I think that all is needed to know is that each contact is stored under [friend_0] [friend_3] [friend_16] etc.

Offline

#8 2011-12-02 10:56:57

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

@rockin turtle
All I see is http://x45.img-up.net/?up=1ob4cawq.png
When I start linphonec I see a blank rectangle.

The file in question, where the contacts are stored in, is "~/.linphonerc"

done < <(grep -B 1 url linphone))
done < <(grep -B 1 url .linphonerc))
$ grep -B 1 url .linphonerc
[friend_0]
url="Echo Test (ekiga.net)" <sip:500@ekiga.net>
--
[friend_1]
url="Echo test (010600)" <sip:*010600@ekiga.net>

I think that we can do without -B or -A, just grep the url. Only [friend_<NUMBER>] entried have url under them.

When I have replaced this text in your script and executed "linphonecsh init" I have got [friend_<NUMBER>] instead of names
friendiqahf.jpg

Edit: I can call when I click on these entries.


The command $ linphonecsh init is need to be execute in order to start linphonec

$ linphonecsh
Usage:
linphonecsh <action> [arguments]
where action is one of
	init		: spawn a linphonec daemon (first step to make other actions)
			followed by the arguments sent to linphonec
	generic		: sends a generic command to the running linphonec daemon
			followed by the generic command surrounded by quotes,
			 for example "call sip:joe@example.net"
	register	: register; arguments are 
			--host <host>
			--username <username>
			--password <password>
	unregister	: unregister
	dial		: dial <sip uri or number>
	status		: can be 'status register', 'status autoanswer' or 'status hook'
	soundcard	: can be 'soundcard capture', 'soundcard playback', 'soundcard ring',
			 followed by an optional number representing the index of the soundcard,
			 in which case the soundcard is set instead of just read.
	exit		: make the linphonec daemon to exit.

Note, the first script did not work after adding a dot to linphonerc.

Last edited by RedArcher (2011-12-02 10:59:27)

Offline

#9 2011-12-03 02:46:53

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Sorry about the

done < <(grep -B 1 url linphone))

try

done < <(grep -B 1 url ~/.linphonerc))

instead.

The only reason for the -B in the above is to get the [friend_N] label displayed in your menu.

It seems to me that your linphone-openbox script should do the 'linphonesch init'.  If it doesn't, then I don't know what else it would be doing.

Try this:

#!/bin/bash

contacts=$(while read line; do
	[[ "$line" =~ ^-- ]] && echo || echo -n "$line "
done < <(grep -B 1 url ~/.linphonerc))

cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<openbox_pipe_menu>
EOF

if pidof linphonec; then
	cat << EOF
  <item label="Exit">
    <action name="Execute">
      <execute>
        linphonecsh exit
      </execute>
    </action>
  </item>
EOF
	while read line; do
		label=$(grep -o '\[.*\]' <<< "$line")
		cmd=$(grep -o 'sip:[^>]*' <<< "$line")
		echo  "  <item label=\"$label\">"
		echo  '    <action name="Execute">'
		echo  "      <execute>linphonecsh dial $cmd</execute>"
		echo $'    </action>\n  </item>'
	done <<< "$contacts"
else
	cat << EOF
  <item label="Init">
    <action name="Execute">
      <execute>
        linphonecsh init
      </execute>
    </action>
  </item>
EOF
fi

echo '</openbox_pipe_menu>'

Offline

#10 2011-12-03 03:14:50

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

I see the word init instead of start (never mind, easy to change)
You have added an exit entry at the top, which seems to work.

I am still getting [friend_<NUMBER>] instead of names.

Offline

#11 2011-12-03 04:20:53

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Well, it is reading your ~/.linphonerc file, to determine what to put in the menu.

Check that file to see what you have in there.

Offline

#12 2011-12-03 04:39:32

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

It is the same structure that I have posted at the begining of the thread

--
[friend_11]
url="Echo test (031600)" <sip:*031600@ekiga.net>
--
[friend_12]
url="Echo test (061600)" <sip:*061600@ekiga.net>
--
[friend_13]
url="Idea SIP's weird voice mail message" <sip:*850**12345@ekiga.net>
--

Instead of [friend_11], as it is now, I should see Echo test (031600)

   

				<item label="Echo test (031600)">
					<action name="Execute">
						<execute>
							linphonecsh dial sip:*031600@ekiga.net
						</execute>
					</action>
				</item>
	

Is it necessary to grep  the [friend_<NUMBER>] lines? (-B)

Edit: Do not fetch [friend_<NUMBER>] (label=$(grep -o '\[.*\]' <<< "$line")), fetch url="THIS_PART" <sip:*850**12345@ekiga.net> ;-)

Last edited by RedArcher (2011-12-03 05:42:47)

Offline

#13 2011-12-03 05:33:24

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Opps, sorry again.  I guess I really didn't understand what you wanted, my apologies.  You are correct, you don't need the -B.

Try this:

#!/bin/bash

cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<openbox_pipe_menu>
EOF

if pidof linphonec; then
	cat << EOF
  <item label="Exit">
    <action name="Execute">
      <execute>
        linphonecsh exit
      </execute>
    </action>
  </item>
EOF
	while read line; do
		label="${line#*\"}"
		cmd=$(grep -o 'sip:[^>]*' <<< "$line")
		echo  "  <item label=\"${label%\"*}\">"
		echo  '    <action name="Execute">'
		echo  "      <execute>linphonecsh dial \"$cmd\"</execute>"
		echo $'    </action>\n  </item>'
	done < <(grep url ~/.linphonerc)
else
	cat << EOF
  <item label="Init">
    <action name="Execute">
      <execute>
        linphonecsh init
      </execute>
    </action>
  </item>
EOF
fi

echo '</openbox_pipe_menu>'

Last edited by rockin turtle (2011-12-03 05:37:35)

Offline

#14 2011-12-03 05:45:45

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Oops, I have edited my post :-P

WUWUWUWUWUWUWUWUWUWUWUYYYYYYYYYAAAAAA!!
Thank you so much ^_^

Offline

#15 2011-12-04 07:04:56

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

This is an old menu
old

#!/bin/bash

cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<openbox_pipe_menu>
EOF

if pidof linphonec; then
	cat << EOF
	<separator label="Current Call"/>
	<item label="Hold Call">
		<action name="Execute">
			<execute>
				linphonecsh generic pause
			</execute>
		</action>
	</item>
	<item label="Resume Call">
		<action name="Execute">
			<execute>
				linphonecsh generic resume
			</execute>
		</action>
	</item>
	<separator />
	<item label="Hang up">
		<action name="Execute">
			<execute>
				linphonecsh generic terminate
			</execute>
		</action>
	</item>
	<separator label="Contacts"/>
EOF
	while read line; do
		label="${line#*\"}"
		cmd=$(grep -o 'sip:[^>]*' <<< "$line")
		echo  "	<item label=\"${label%\"*}\">"
		echo  '		<action name="Execute">'
		echo  "			<execute>linphonecsh dial \"$cmd\"</execute>"
		echo $'		</action>\n  </item>'
#	done < <(grep url ~/.linphonerc)
	done < <(sort ~/.linphonerc | grep url)
	cat << EOF
	<separator label="Microphone"/>
	<item label="Unmute microphone">
		<action name="Execute">
			<execute>
				linphonecsh generic unmute
			</execute>
		</action>
	</item>
	<item label="Mute microphone">
		<action name="Execute">
			<execute>
				linphonecsh generic mute
			</execute>
		</action>
	</item>
EOF
else
	cat << EOF
	<item label="Turn Telephone ON">
		<action name="Execute">
			<execute>
				linphonecsh init
			</execute>
		</action>
	</item>
EOF
fi

echo '</openbox_pipe_menu>'

This is a new menu
current



A few interesting things:

Show all the current calls with their id and status.

linphonecsh generic help calls
 linphonecsh generic calls
ID		Destination				Status
---------------------------------------------------------------------
11	<sip:*031600@ekiga.net>			Paused
12	<sip:*850**12345@ekiga.net>			Running

Edit
There is also a Dialing out status which I don't find as relevant for what I need.

2	<sip:*031600@ekiga.net>			Dialing out

Get the number of active calls

linphonecsh generic calls | grep sip | wc -l
linphonecsh generic calls | grep sip | awk '{print $1" "$3}'
11 Paused
12 Running
linphonecsh generic calls | grep sip | awk '{print $1" "$2" "$3}'
11 <sip:*031600@ekiga.net> Paused
12 <sip:*850**12345@ekiga.net> Running

Available commans

linphonecsh generic help
Commands are:
---------------------------
      help	Print commands help.
      call	Call a SIP uri or number
     calls	Show all the current calls with their id and status.
      chat	Chat with a SIP uri
 terminate	Terminate a call
    answer	Answer a call
     pause	pause a call
    resume	resume a call
  transfer	Transfer a call to a specified destination.
      mute	Mute microphone and suspend voice transmission.
    unmute	Unmute microphone and resume voice transmission.
  duration	Print duration in seconds of the last call.
autoanswer	Show/set auto-answer mode
     proxy	Manage proxies
 soundcard	Manage soundcards
    webcam	Manage webcams
      ipv6	Use IPV6
       nat	Set nat address
      stun	Set stun server address
  firewall	Set firewall policy
 call-logs	Calls history
    friend	Manage friends
      play	play a wav file
    record	record to a wav file
      quit	Exit linphonec
---------------------------
Type 'help <command>' for more details or
     'help advanced' to list additional commands.

What is the proper "if x then y" format for Bash?

If 1 call then:

	<separator label="Current Call"/>
	<item label="Hold Call">
		<action name="Execute">
			<execute>
				linphonecsh generic pause
			</execute>
		</action>
	</item>
	<item label="Resume Call">
		<action name="Execute">
			<execute>
				linphonecsh generic resume
			</execute>
		</action>
	</item>
	<separator />
	<item label="Hang up">
		<action name="Execute">
			<execute>
				linphonecsh generic terminate
			</execute>
		</action>
	</item>

Example for simultaneous calls.

 linphonecsh generic calls
ID		Destination				Status
---------------------------------------------------------------------
11	<sip:*031600@ekiga.net>			Paused
12	<sip:*850**12345@ekiga.net>			Running

If more than 1 call then:
Idea menu 1

	<separator label="Calls Options"/>
	<menu id="CALL_ID-11" label="User_Name_of_ID-11">
	<item label="Resume Call">
		<action name="Execute">
			<execute>
				linphonecsh generic 'resume 11'
			</execute>
		</action>
	</item>
	<item label="Hold Call">
		<action name="Execute">
			<execute>
				linphonecsh generic 'pause 11'
			</execute>
		</action>
	</item>
	<separator />
	<item label="Hang up">
		<action name="Execute">
			<execute>
				linphonecsh generic 'terminate 11'
			</execute>
		</action>
	</menu>
	<menu id="CALL_ID-2" label="User_Name_of_ID-12">
	<item label="Resume Call">
		<action name="Execute">
			<execute>
				linphonecsh generic 'resume 12'
			</execute>
		</action>
	</item>
	<item label="Hold Call">
		<action name="Execute">
			<execute>
				linphonecsh generic 'pause 12'
			</execute>
		</action>
	</item>
	<separator />
	<item label="Hang up">
		<action name="Execute">
			<execute>
				linphonecsh generic 'terminate 12'
			</execute>
		</action>
	</menu>

Idea menu 2 (better)

	<separator label="Current Call"/>
	<item label="Resume Call">
		<action name="Execute">
			<execute>
				linphonecsh generic 'resume 12'
			</execute>
		</action>
	</item>
	<item label="Hold Call">
		<action name="Execute">
			<execute>
				linphonecsh generic 'pause 12'
			</execute>
		</action>
	</item>
	<separator />
	<item label="Hang up">
		<action name="Execute">
			<execute>
				linphonecsh generic 'terminate 12'
			</execute>
		</action>
	</item>
	<separator label="Paused Calls"/>
	<menu id="CALL_ID-11" label="User_Name_of_ID-11">
	<item label="Resume Call">
		<action name="Execute">
			<execute>
				linphonecsh generic 'resume 11'
			</execute>
		</action>
	</item>
	<separator />
	<item label="Hang up">
		<action name="Execute">
			<execute>
				linphonecsh generic 'terminate 11'
			</execute>
		</action>
	</item>
	</menu>


Hold and Resume should be a one switching entry.

Last edited by RedArcher (2011-12-04 07:09:27)

Offline

#16 2011-12-04 21:09:14

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Well, hopefully I understand what you want.

Try this:

#!/bin/bash

calldata="$(linphonecsh generic calls | awk '/sip/{print $1, $2, $3}')"

get_status () {
	while read line; do
		url=$(grep -o 'sip:[^>]*' <<< "$line")
		stat=$(cut -d ' ' -f1,3 <<< "$line")
		[[ "$1" == "$url" ]] && echo "$stat"
	done <<< "$2"
}

cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<openbox_pipe_menu>
EOF

if pidof linphonec; then
	cat << EOF
	<separator label="Current Call"/>
	<item label="Hold Call">
		<action name="Execute">
			<execute>
				linphonecsh generic pause
			</execute>
		</action>
	</item>
	<item label="Resume Call">
		<action name="Execute">
			<execute>
				linphonecsh generic resume
			</execute>
		</action>
	</item>
	<separator />
	<item label="Hang up">
		<action name="Execute">
			<execute>linphonecsh generic terminate</execute>
		</action>
	</item>
EOF
	while read line; do
		label="${line#*\"}"
		label="${label%\"*}"
		cmd=$(grep -o 'sip:[^>]*' <<< "$line")
		stat=($(get_status "$cmd" "$calldata"))
		if [ ${#stat} -gt 0 ]; then
			if [[ "${stat[1]}" =~ Pau ]]; then
				echo "	<item label=\"Resume $label\">"
				echo '		<action name="Execute">'
				echo "			<execute>linphonecsh generic \"resume ${stat[0]}\"</execute>"
			else
				echo "	<item label=\"Pause $label\">"
				echo '		<action name="Execute">'
				echo "			<execute>linphonecsh generic \"pause ${stat[0]}\"</execute>"
			fi
		else
			echo "	<item label=\"Call $label\">"
			echo '		<action name="Execute">'
			echo "			<execute>linphonecsh dial \"$cmd\"</execute>"
		fi
		echo $'		</action>\n\t</item>'
	done < <(grep url ~/.linphonerc | sort)
	cat << EOF
	<separator label="Microphone"/>
	<item label="Unmute microphone">
		<action name="Execute">
			<execute>
				linphonecsh generic unmute
			</execute>
		</action>
	</item>
	<item label="Mute microphone">
		<action name="Execute">
			<execute>
				linphonecsh generic mute
			</execute>
		</action>
	</item>
EOF
else
	cat << EOF
	<item label="Turn Telephone ON">
		<action name="Execute">
			<execute>
				linphonecsh init
			</execute>
		</action>
	</item>
EOF
fi

echo '</openbox_pipe_menu>'

Offline

#17 2011-12-07 09:16:25

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Thank you for your effort.
No, this is not what I described.
111uin1s.jpg

How can I associate the ID Call numbers to the SIP addresses?

11	<sip:*031600@ekiga.net>			Paused
12	<sip:*850**12345@ekiga.net>			Running

Or maybe it isn't really needed, since we wc -l-ing the number of active calls and grep-ing the lines one by one... (in case I'll have a problem with this, I'll post here)

I will post a script in a few days.
I will use parts of your code and obmocmenu

The Pause/Unpause (elif, else if) is the most basic thing that I need:

    echo "<separator label=\"Control\" />"

    if [ "${state}" = "PLAY" ] || [ "${state}" = "PAUSE" ]; then
        echo "<item label=\"_Next\">"
        echo "<action name=\"Execute\">"
        echo "<command>$mocp --next</command>"
        echo "</action>"
        echo "</item>"

        echo "<item label=\"Pre_vious\">"
        echo "<action name=\"Execute\">"
        echo "<command>$mocp --previous</command>"
        echo "</action>"
        echo "</item>"

        if [ "${state}" = "PLAY" ]; then
            echo "<item label=\"_Pause\">"
            echo "<action name=\"Execute\">"
            echo "<command>$mocp --toggle-pause</command>"
            echo "</action>"
            echo "</item>"
        elif [ "${state}" = "PAUSE" ]; then
            echo "<item label=\"_Unpause\">"
            echo "<action name=\"Execute\">"
            echo "<command>$mocp --toggle-pause</command>"
            echo "</action>"
            echo "</item>"
        fi

        echo "<item label=\"_Stop\">"
        echo "<action name=\"Execute\">"
        echo "<command>$mocp --stop</command>"
        echo "</action>"
        echo "</item>"

Offline

#18 2011-12-09 06:49:11

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Make SIP (VoIP) calls with LinPhone from an Openbox pipe-menu

Well, actually, what I posted does get you the association between the ID call number and sip address.

The variable 'stat' is an array.  For the example you gave

11	<sip:*031600@ekiga.net>			Paused
12	<sip:*850**12345@ekiga.net>			Running

In the while loop, if cmd contains 'sip:*031600@ekiga.net', then stat[0] would contain '11' and stat[1] would contain 'Paused'. If cmd contains any sip address for a call that is inactive (not paused or running) then stat will be an empty array.  ${#stat} contains the length of the stat array.  If you have an active (paused or running) call, the length of the stat array will be 2.  If there is no call for the given sip address, the length will be 0.

The picture you showed is when none of your friends has been called.  Try again with one of your friends called (either paused or active), look at what the menu shows and see if selecting the menu item does what you expect.

For the script I posted, if you have a call to sip:*031600@ekiga.net (for instance) paused, the associated menu item would show up as:

Resume Echo Test (031600)

and the pipe menu would contain the following:

	<item label="Resume Echo Test (031600)">
		<action name="Execute">
			<execute>linphonecsh generic "resume 11"</execute>
		</action>
	</item>

Offline

Board footer

Powered by FluxBB