Bug 515768: Fennec needs a task switch button in titlebar for n900 (component), r=blassey
--- a/mobile/components/Makefile.in
+++ b/mobile/components/Makefile.in
@@ -54,15 +54,12 @@ EXTRA_COMPONENTS = \
alertsService.js \
xpiDialogService.js \
downloadManagerUI.js \
helperAppDialog.js \
promptService.js \
$(NULL)
DIRS = protocols \
+ phone \
$(NULL)
-ifdef WINCE
-DIRS += phone
-endif
-
include $(topsrcdir)/config/rules.mk
--- a/mobile/components/phone/Makefile.in
+++ b/mobile/components/phone/Makefile.in
@@ -54,19 +54,25 @@ REQUIRES = \
xpcom \
string \
pref \
$(NULL)
CPPSRCS = nsPhoneSupport.cpp
XPIDLSRCS = nsIPhoneSupport.idl
+
EXTRA_DSO_LDOPTS += \
$(XPCOM_GLUE_LDOPTS) \
$(NSPR_LIBS) \
$(NULL)
+ifdef MOZ_PLATFORM_HILDON
+LOCAL_INCLUDES += $(MOZ_DBUS_GLIB_CFLAGS)
+EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS)
+endif
+
ifdef WINCE
OS_LIBS += $(call EXPAND_LIBNAME, aygshell cellcore)
endif
include $(topsrcdir)/config/rules.mk
--- a/mobile/components/phone/nsIPhoneSupport.idl
+++ b/mobile/components/phone/nsIPhoneSupport.idl
@@ -48,9 +48,14 @@ interface nsIPhoneSupport : nsISupports
*
* @param telephoneNumber this is the telephone to dial.
* @param telephoneDescription this is an optional
* description of the telephone number.
* @param aPrompt this indicates whether to display the confirm call dialog
* before dialing
*/
void makeCall(in wstring telephoneNumber, in wstring telephoneDescription, in boolean aPrompt);
+
+ /**
+ * This method displays a UI to switch to (or launch) a different task
+ */
+ void switchTask();
};
--- a/mobile/components/phone/nsPhoneSupport.cpp
+++ b/mobile/components/phone/nsPhoneSupport.cpp
@@ -33,18 +33,25 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
+#ifdef WINCE_WINDOWS_MOBILE
#include <windows.h>
#include <phone.h>
+#endif
+
+#ifdef MOZ_PLATFORM_HILDON
+#include <dbus/dbus.h>
+#endif
+
#include "nsStringAPI.h"
#include "nsIPhoneSupport.h"
#include "nsIGenericFactory.h"
class nsPhoneSupport : public nsIPhoneSupport
{
public:
@@ -58,39 +65,64 @@ public:
NS_IMPL_ISUPPORTS1(nsPhoneSupport, nsIPhoneSupport)
NS_IMETHODIMP
nsPhoneSupport::MakeCall(const PRUnichar *telephoneNumber, const PRUnichar *telephoneDescription, PRBool aPrompt)
{
long result = -1;
+#ifdef WINCE_WINDOWS_MOBILE
typedef LONG (*__PhoneMakeCall)(PHONEMAKECALLINFO *ppmci);
HMODULE hPhoneDLL = LoadLibraryW(L"phone.dll");
- if(hPhoneDLL)
- {
- __PhoneMakeCall MakeCall = (__PhoneMakeCall) GetProcAddress( hPhoneDLL,
- "PhoneMakeCall");
- if(MakeCall)
- {
+ if (hPhoneDLL) {
+ __PhoneMakeCall MakeCall = (__PhoneMakeCall) GetProcAddress(hPhoneDLL,
+ "PhoneMakeCall");
+ if (MakeCall) {
PHONEMAKECALLINFO callInfo;
callInfo.cbSize = sizeof(PHONEMAKECALLINFO);
callInfo.dwFlags = aPrompt ? PMCF_PROMPTBEFORECALLING : PMCF_DEFAULT;
callInfo.pszDestAddress = telephoneNumber;
callInfo.pszAppName = nsnull;
callInfo.pszCalledParty = telephoneDescription;
callInfo.pszComment = nsnull;
result = MakeCall(&callInfo);
}
FreeLibrary(hPhoneDLL);
}
+#endif
+
return (result == 0) ? NS_OK : NS_ERROR_FAILURE;
}
+NS_IMETHODIMP
+nsPhoneSupport::SwitchTask()
+{
+#ifdef MOZ_PLATFORM_HILDON
+ DBusError error;
+ dbus_error_init(&error);
+
+ DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, &error);
+
+ DBusMessage *msg = dbus_message_new_signal("/com/nokia/hildon_desktop",
+ "com.nokia.hildon_desktop",
+ "exit_app_view");
+
+ if (msg) {
+ dbus_connection_send(conn, msg, NULL);
+ dbus_message_unref(msg);
+ dbus_connection_flush(conn);
+ }
+ return NS_OK;
+#else
+ return NS_ERROR_NOT_IMPLEMENTED;
+#endif
+}
+
//------------------------------------------------------------------------------
// XPCOM REGISTRATION BELOW
//------------------------------------------------------------------------------
#define nsPhoneSupport_CID \
{ 0x2a08c9e4, 0xf853, 0x4f02, \
{0x88, 0xd8, 0xd6, 0x2f, 0x27, 0xca, 0x06, 0x85} }