2010-11-22 13:23:40 -08:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-11-22 13:23:40 -08:00
|
|
|
|
2011-02-01 11:11:08 -08:00
|
|
|
#if (MOZ_PLATFORM_MAEMO == 5)
|
2010-11-22 13:23:40 -08:00
|
|
|
#include <dbus/dbus.h>
|
|
|
|
#include <mce/dbus-names.h>
|
|
|
|
#endif
|
2011-08-16 09:27:01 -07:00
|
|
|
#if defined(MOZ_ENABLE_QTMOBILITY)
|
|
|
|
#include <QFeedbackEffect>
|
|
|
|
using namespace QtMobility;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "nsHapticFeedback.h"
|
2010-11-22 13:23:40 -08:00
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsHapticFeedback, nsIHapticFeedback)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHapticFeedback::PerformSimpleAction(PRInt32 aType)
|
|
|
|
{
|
2010-11-28 23:33:34 -08:00
|
|
|
#if (MOZ_PLATFORM_MAEMO == 5)
|
2010-11-22 13:23:40 -08:00
|
|
|
DBusError err;
|
|
|
|
dbus_error_init(&err);
|
|
|
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
|
|
|
|
if (dbus_error_is_set(&err)) {
|
|
|
|
dbus_error_free(&err);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
if (nsnull == connection) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_connection_set_exit_on_disconnect(connection,false);
|
|
|
|
|
|
|
|
DBusMessage* msg =
|
|
|
|
dbus_message_new_method_call(MCE_SERVICE, MCE_REQUEST_PATH,
|
|
|
|
MCE_REQUEST_IF, MCE_ACTIVATE_VIBRATOR_PATTERN);
|
|
|
|
|
|
|
|
if (!msg) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
dbus_message_set_no_reply(msg, true);
|
2010-11-22 13:23:40 -08:00
|
|
|
|
|
|
|
DBusMessageIter iter;
|
|
|
|
dbus_message_iter_init_append(msg, &iter);
|
|
|
|
const char* pattern = "PatternTouchscreen";
|
|
|
|
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &pattern);
|
|
|
|
|
|
|
|
if (dbus_connection_send(connection, msg, NULL)) {
|
|
|
|
dbus_connection_flush(connection);
|
|
|
|
dbus_message_unref(msg);
|
|
|
|
} else {
|
|
|
|
dbus_message_unref(msg);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-08-16 09:27:01 -07:00
|
|
|
#elif defined(MOZ_ENABLE_QTMOBILITY)
|
|
|
|
if (aType == ShortPress)
|
|
|
|
QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeBasicButton);
|
|
|
|
if (aType == LongPress)
|
|
|
|
QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeLongPress);
|
2010-11-22 13:23:40 -08:00
|
|
|
#endif
|
2011-08-16 09:27:01 -07:00
|
|
|
|
2011-05-24 18:24:49 -07:00
|
|
|
return NS_OK;
|
2010-11-22 13:23:40 -08:00
|
|
|
}
|