View Single Post
Posts: 55 | Thanked: 72 times | Joined on Nov 2009
#5
Implementing the "End call" menu item took a fair bit of exploration and experimentation, so I want to document how it works as an example for how to implement more complex power-key menu items that use D-Bus and keyfile-based visibility.

Code:
<powerkeymenu path="/">
 <menuitem priority="10" name="End call" visible="yes">
  <keyfile>/var/run/mce/call</keyfile>
  <icon>red_end_call</icon>
  <callback service="com.nokia.csd.Call" path="/com/nokia/csd/call" interface="com.nokia.csd.Call" method="Release" bus="system">
  </callback>
 </menuitem>
</powerkeymenu>
A power-button menu file uses XML, and requires a root tag of <powerkeymenu path="/">.

The "End call" item uses a <menuitem> tag, and name="End call" attribute specifies the text that appears in the menu item. (I should really add a <po> tag in the <menuitem> so that this uses the same localized text for "End call" that the Phone UI does.)

priority="10" determines where the item appears in the power button menu. Smaller numbers appear earlier in the menu. priority 10 makes "End call" appear before all the existing defined menu items.

<keyfile>/var/run/mce/call</keyfile> and the visible="yes" attribute on the <menuitem> make the "End call" button only appear when on a call. The file /var/run/mce/call contains "yes" when on a call and "no" when not on a call; visible="yes" says to make this item visible only when the keyfile contains "yes".

The <icon> tag specifies the icon; red_end_call corresponds to the icon used by the phone UI.

<callback> says to make a D-Bus call when running this menu item. The method com.nokia.csd.Call.Release will end the current call. (Everything I've found says that I should use Telepathy calls for this instead, but I haven't found the right D-Bus interface to use for that; suggestions welcome.) Since the Release method doesn't take any arguments, I don't have to specify any <argument> elements inside the <callback>.

Last edited by josh; 2010-08-26 at 07:56.
 

The Following 6 Users Say Thank You to josh For This Useful Post: