1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 et sw=2 tw=80: */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Corporation code.
18 * The Initial Developer of the Original Code is Mozilla Foundation.
19 * Portions created by the Initial Developer are Copyright (C) 2010
20 * the Initial Developer. All Rights Reserved.
23 * Oleg Romashin <romaxa@gmail.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 #include "nsNativeAppSupportBase.h"
43 #ifdef MOZ_ENABLE_LIBCONIC
44 #include <glib-object.h>
47 #if (MOZ_PLATFORM_MAEMO == 5)
51 class nsNativeAppSupportQt
: public nsNativeAppSupportBase
54 NS_IMETHOD
Start(PRBool
* aRetVal
);
55 NS_IMETHOD
Stop(PRBool
* aResult
);
56 #if (MOZ_PLATFORM_MAEMO == 5)
57 // Osso context must be initialized for maemo5 otherwise we will be killed in ~20 seconds
58 osso_context_t
*m_osso_context
;
63 nsNativeAppSupportQt::Start(PRBool
* aRetVal
)
65 NS_ASSERTION(gAppData
, "gAppData must not be null.");
68 #ifdef MOZ_ENABLE_LIBCONIC
72 #if (MOZ_PLATFORM_MAEMO == 5)
73 /* Initialize maemo application
75 The initalization name will be of the form "Vendor.Name".
76 If a Vendor isn't given, then we will just use "Name".
78 Note that this value must match your X-Osso-Service name
79 defined in your desktop file. If it doesn't, the OSSO
80 system will happily kill your process.
82 nsCAutoString applicationName
;
83 if (gAppData
->vendor
) {
84 applicationName
.Append(gAppData
->vendor
);
85 applicationName
.Append(".");
87 applicationName
.Append(gAppData
->name
);
88 ToLowerCase(applicationName
);
90 m_osso_context
= osso_initialize(applicationName
.get(),
91 gAppData
->version
? gAppData
->version
: "1.0",
95 /* Check that initilialization was ok */
96 if (m_osso_context
== nsnull
) {
97 return NS_ERROR_FAILURE
;
105 nsNativeAppSupportQt::Stop(PRBool
* aResult
)
107 NS_ENSURE_ARG(aResult
);
110 #if (MOZ_PLATFORM_MAEMO == 5)
111 if (m_osso_context
) {
112 osso_deinitialize(m_osso_context
);
113 m_osso_context
= nsnull
;
121 NS_CreateNativeAppSupport(nsINativeAppSupport
** aResult
)
123 nsNativeAppSupportBase
* native
= new nsNativeAppSupportQt();
125 return NS_ERROR_OUT_OF_MEMORY
;