Bug 515768: Fennec needs a task switch button in titlebar for n900 (component), r=blassey

This commit is contained in:
Mark Finkle 2009-09-23 12:09:54 -04:00
parent f3b0307610
commit 40a85b3e9f
4 changed files with 50 additions and 10 deletions

View File

@ -59,10 +59,7 @@ EXTRA_COMPONENTS = \
$(NULL)
DIRS = protocols \
phone \
$(NULL)
ifdef WINCE
DIRS += phone
endif
include $(topsrcdir)/config/rules.mk

View File

@ -59,11 +59,17 @@ REQUIRES = \
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

View File

@ -53,4 +53,9 @@ interface nsIPhoneSupport : nsISupports
* 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();
};

View File

@ -38,8 +38,15 @@
*
* ***** 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"
@ -63,15 +70,14 @@ nsPhoneSupport::MakeCall(const PRUnichar *telephoneNumber, const PRUnichar *tele
{
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;
@ -83,9 +89,35 @@ nsPhoneSupport::MakeCall(const PRUnichar *telephoneNumber, const PRUnichar *tele
}
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
//------------------------------------------------------------------------------