[prev in list] [next in list] [prev in thread] [next in thread]
List: moblin-commits
Subject: [Moblin-Commits] mobile-basic-flash: Changes to 'master'
From: horace.li () moblin ! org (Horace Li)
Date: 2008-02-27 23:42:24
Message-ID: 20080228074222.8872F92C0E9 () moblin ! org
[Download RAW message or body]
debian/changelog | 14 +
src/Makefile.am | 2 +-
src/mobile-basic-home-plugin.c | 1084 +++++++++++++++++++++++++++++++++++++
src/mobile-basic-home-plugin.cpp | 1093 --------------------------------------
src/mobile-basic-home-plugin.h | 6 +-
src/mobile-basic-home.desktop.in | 3 +-
6 files changed, 1103 insertions(+), 1099 deletions(-)
New commits:
commit 5eabfce0d7cee1b66826d3102e81c995b542b338
Author: Horace Li <horace.li@intel.com>
Date: Thu Feb 28 15:44:15 2008 +0800
[ Bill Filler ]
* fixed desktop file to use Type=default rather then Type=Link
* fixed problem with undefined symbol when trying to load plugin:
- removed unecessary includes
- corrected problems with mobile-basic-flash-plugin.h
- renamed file from .cpp to .c
[ Horace Li ]
- removed unused variables and fixed compilation warnings.
Diff in this email is a maximum of 400 lines.
diff --git a/debian/changelog b/debian/changelog
index 00e7270..bf20a89 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
+mobile-basic-flash (0.32) gaston; urgency=low
+
+ [ Bill Filler ]
+ * fixed desktop file to use Type=default rather then Type=Link
+ * fixed problem with undefined symbol when trying to load plugin:
+ - removed unecessary includes
+ - corrected problems with mobile-basic-flash-plugin.h
+ - renamed file from .cpp to .c
+
+ [ Horace Li ]
+ - removed unused variables and fixed compilation warnings.
+
+ -- Horace Li <horace.li@intel.com> Thu, 28 Feb 2008 15:40:15 +0800
+
mobile-basic-flash (0.31) gaston; urgency=low
* Added support for reading the native language versions of the Name
diff --git a/src/Makefile.am b/src/Makefile.am
index 0a32ab3..aa1300b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,6 @@ hildonhomeentry_DATA = mobile-basic-home.desktop
libmobilebasichome_la_LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(LIBOSSO_LIBS) \
$(LIBHILDONDESKTOP_LIBS) $(LIBHILDONWM_LIBS) $(MOZEMBED_LIBS)
-libmobilebasichome_la_SOURCES = mobile-basic-home-plugin.cpp
+libmobilebasichome_la_SOURCES = mobile-basic-home-plugin.c
CLEANFILES = *~ *.la *.desktop *.o *.so
diff --git a/src/mobile-basic-home-plugin.c b/src/mobile-basic-home-plugin.c
new file mode 100644
index 0000000..ff7d871
--- /dev/null
+++ b/src/mobile-basic-home-plugin.c
@@ -0,0 +1,1084 @@
+/*
+ * This plugin based on the example dummy plugin from the Maemo
+ * maemo-af-desktop repository. Original copyright declaration:
+ * Lucas Rocha <lucas.rocha@nokia.com>
+ * Copyright 2006 Nokia Corporation.
+ *
+ * Modifcations transform the example to an embedded mozilla home applet:
+ * Bob Spencer <bob.spencer@intel.com>
+ * Copyright 2007 Intel Corporation
+ *
+ * Contributors:
+ * Michael Frey <michael.frey@pepper.com>
+ * Rusty Lynch <rusty.lynch@intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/resource.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <glib-object.h>
+
+#include "mobile-basic-home-plugin.h"
+#include "gtkmozembed.h"
+
+#include <libhildondesktop/libhildondesktop.h>
+#include <libhildonwm/hd-wm.h>
+#include <libosso.h>
+#include <hildon/hildon-banner.h>
+#include <hildon/hildon-note.h>
+
+
+#define FILE_URL_PREFIX "file://"
+#define PROFILE_DIR "/usr/share/mobile-basic-flash"
+#define HOME_HTML "home.html"
+
+#define PROFILE_NAME "mozapplet"
+#define MARQUEE_HEIGHT 52
+#define DESKTOP_FILE_SUFFIX ".desktop"
+#define DESKTOP_GROUP "Desktop Entry"
+
+#define DESKTOP_DIR "/usr/share/mobile-basic-flash/applications"
+#define CP_PLUGINS_DIR "/usr/share/applications/hildon-control-panel"
+
+//TBD: use theme pattern to get fonts
+#define ICON_DIR "/usr/share/mobile-basic-flash/icons"
+
+//TBD: use gconf header to replace all gconf defines
+#define BKGD_PATH "/desktop/gnome/background"
+#define BKGD_FILE BKGD_PATH "/picture_filename"
+#define BKGD_PIC_OPTIONS BKGD_PATH "/picture_options"
+#define BKGD_PRIMARY_COLOR BKGD_PATH "/primary_color"
+
+#define INTERFACE_PATH "/desktop/gnome/interface"
+#define GTK_THEME INTERFACE_PATH "/gtk_theme"
+#define ICON_THEME INTERFACE_PATH "/icon_theme"
+#define FONT_NAME INTERFACE_PATH "/font_name"
+
+//gconf location of custom flash movie, and hide/show marquee
+#define HILDON_DESKTOP_GCONF_PATH "/desktop/hildon"
+#define MARQUEE_KEY HILDON_DESKTOP_GCONF_PATH "/marquee/hide"
+#define HOMEPAGE_KEY HILDON_DESKTOP_GCONF_PATH "/htmlhomeplugin/homepage"
+#define FLASHMOVIE_KEY HILDON_DESKTOP_GCONF_PATH "/htmlhomeplugin/flashmoviename"
+
+#define MARQUEE_GCONF_PATH "/apps/marquee-plugins"
+#define ACTIVE_CAT_KEY MARQUEE_GCONF_PATH "/active"
+
+#define DialogDestroy 111
+
+#define MB_HOME_PLUGIN_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), MOBILE_BASIC_TYPE_HOME_PLUGIN, \
MobileBasicHomePluginPrivate)) +
+HD_DEFINE_PLUGIN (MobileBasicHomePlugin, mobile_basic_home_plugin, \
HILDON_DESKTOP_TYPE_HOME_ITEM); +
+static GtkWidget* launch_banner = NULL;
+
+//#define LOG_FILE
+#ifdef LOG_FILE
+#define DBG_LOG trace
+static void trace (const gchar * msg) {
+ FILE *fp;
+ if (fp = fopen("/tmp/mobile_trace.log", "a")) {
+ fprintf (fp, "%s\n", msg);
+ fclose (fp);
+ }
+}
+#else
+#define DBG_LOG
+#endif
+
+
+typedef struct {
+ int index;
+ gchar *plugin;
+ gchar *name;
+ gchar *icon;
+ gchar *exec;
+ gchar *service;
+ gchar *filename;
+ gchar *id;
+ gchar *cat;
+} application_entry_t;
+
+struct _plugin_context_t {
+ GtkWidget *container;
+ GList *app_list;
+ osso_context_t *osso_context;
+ GConfClient *client;
+ const char *active;
+};
+
+
+static GdkFilterReturn mobile_basic_home_x_event_handler (GdkXEvent *xevent, \
GdkEvent *event, gpointer data); +static void home_screen_changed \
(HildonDesktopHomeItem *item); +static void start_plugin(plugin_context_t *, gchar*);
+
+static void update_background(plugin_context_t *context) {
+ gchar *pic, *opt, *color;
+
+ DBG_LOG ("update_background");
+
+ pic = gconf_client_get_string (context->client,BKGD_FILE,NULL);
+ opt = gconf_client_get_string (context->client,BKGD_PIC_OPTIONS,NULL);
+ color = gconf_client_get_string (context->client,BKGD_PRIMARY_COLOR,NULL);
+
+ //if a picture is selected (not "no Wallpaper"), make sure it is valid
+ if ((pic != NULL) &&
+ !g_utf8_validate(pic, -1, NULL) || !g_file_test(pic, G_FILE_TEST_EXISTS)) {
+ pic = g_filename_from_utf8 (pic, -1, NULL,NULL, NULL);
+ }
+
+ gchar *url = g_strdup_printf("javascript:setBackground(['%s', '%s', '%s'])",
+ pic, opt, color);
+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(context->container), url);
+ g_free(url);
+
+ if (pic) {
+ g_free (pic);
+ }
+ if (opt) {
+ g_free (opt);
+ }
+ if (color) {
+ g_free (color);
+ }
+}
+
+
+static void update_theme(plugin_context_t *context) {
+
+ DBG_LOG ("interface_changed");
+
+ gchar *theme, *icon_theme, *font;
+ theme = gconf_client_get_string (context->client, GTK_THEME, NULL);
+ icon_theme = gconf_client_get_string (context->client, ICON_THEME, NULL);
+ font = gconf_client_get_string (context->client, FONT_NAME, NULL);
+
+ //a little hack -- Human is default now, but it doesn't exist.
+ if (!theme || (!strcmp (theme, "Human"))) {
+ theme = g_strdup ("mobilebasic");
+ }
+ if (!icon_theme) {
+ icon_theme = g_strdup ("hicolor");
+ }
+ gchar *url = g_strdup_printf("javascript:setThemeValues(['%s', '%s', '%s'])",
+ theme, icon_theme, font);
+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(context->container), url);
+ g_free(url);
+
+ if (theme) {
+ g_free (theme);
+ }
+ if (icon_theme) {
+ g_free (icon_theme);
+ }
+ if (font) {
+ g_free (font);
+ }
+}
+
+static void dump_application(gpointer data, gpointer ignore)
+{
+ application_entry_t *item = (application_entry_t *)data;
+ g_print("app[%i] = %s\n", item->index, item->exec);
+}
+
+static void __add_application(plugin_context_t *c, application_entry_t *i)
+{
+ gchar *url = g_strdup_printf("javascript:addApp([%i, '%s', '%s'])",
+ i->index,
+ i->name,
+ i->icon);
+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(c->container), url);
+ g_free(url);
+ return;
+}
+
+static void add_application(gpointer data, gpointer payload)
+{
+ application_entry_t *item = (application_entry_t *)data;
+ plugin_context_t *c = (plugin_context_t *)payload;
+ char **catv = g_strsplit(item->cat, ";", 0);
+
+ /*
+ * Handle control panel plugins as a special case, where we
+ * only want to add buttons if the category is "Settings"
+ */
+ if (item->plugin) {
+ if (!g_ascii_strcasecmp("Settings", c->active))
+ __add_application(c, item);
+ return;
+ }
+
+ /*
+ * If any of the ';' delimited entries from the desktop
+ * 'Categories' of the given app match the currently active
+ * category, then add the app to the content.
+ */
+ for ( int i=0; catv[i]; i++ ) {
+ if (!g_ascii_strcasecmp("All", c->active) ||
+ !g_ascii_strcasecmp(catv[i], c->active)) {
+ __add_application(c, item);
+ return;
+ }
+ }
+
+}
+
+static gboolean init_program(plugin_context_t *c)
+{
+ gchar *url;
+
+ update_background(c);
+ update_theme(c);
+ url = g_strdup_printf("javascript:launchDesktop()");
+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(c->container), url);
+ g_free(url);
+
+ return FALSE;
+}
+
+static void hide_banner ()
+{
+ DBG_LOG ("hide_banner");
+ if (launch_banner != NULL) {
+ gtk_widget_destroy(launch_banner);
+ launch_banner = NULL;
+ }
+}
+
+static void show_banner (const gchar *msg)
+{
+ // make sure we are not already showing a launchBanner
+ hide_banner();
+
+ // now show a new launch banner
+ launch_banner = hildon_banner_show_animation(NULL, NULL, msg);
+ gtk_window_set_position(GTK_WINDOW (launch_banner), \
GTK_WIN_POS_CENTER_ALWAYS); +}
+
+//this function parses a full exec string and returns the first portion
+//before the space
+static gchar *parse_exec(const gchar *exec_name)
+{
+ if (exec_name == NULL) {
+ return NULL;
+ }
+
+ gchar *space = strchr(exec_name, ' ');
+ if (space) {
+ gchar *cmd = g_strdup (exec_name);
+ cmd[space - exec_name] = 0;
+ return cmd;
+ }
+
+ return g_strdup (exec_name);
+}
+
+//find a running app with same name/exec path as item passed in
+static HDWMEntryInfo* find_running_app(application_entry_t *item)
+{
+ // check if app is already running, if so show it..
+ GList *applications_list = NULL;
+ HDWMApplication *app = NULL;
+ HDWMEntryInfo *app_info = NULL;
+ HDWM *hdwm = hd_wm_get_singleton();
+
+ // get list of running applications, the app_info for the running
+ // app is based on what is defined in /usr/share/applications/*.desktop
+ // Specifically, the StartupWMClass attribute needs to be correct
+ // in the desktop file or else the app_info won't be correct in this list
+ applications_list = hd_wm_get_applications (hdwm);
+
+ guint len = g_list_length(applications_list);
+ g_debug("find_running_app #running apps=%i\n", len);
+
+ for (int i = 0; i < len; i++) {
+
+ app = HD_WM_APPLICATION(g_list_nth_data(applications_list, i));
+ const gchar *app_name = hd_wm_application_get_name(app);
+ //get the first part of the exec before the space
+ gchar *exec_name = parse_exec(hd_wm_application_get_exec(app));
+ const gchar *class_name = hd_wm_application_get_class_name(app);
+
+ g_debug("searching appName=%s execName=%s className=%s appInfo=%x\n",
+ app_name, exec_name, class_name,
+ HD_WM_ENTRY_INFO(hd_wm_application_get_active_window(app)));
+
+ gchar *item_exec_name = parse_exec(item->exec);
+
+ // look for match based on exec command or name
+ if ((exec_name != NULL && (!g_ascii_strcasecmp(item_exec_name, exec_name))) ||
+ (app_name != NULL && (!g_ascii_strcasecmp(item->name, app_name))))
+ {
+
+ app_info = HD_WM_ENTRY_INFO(hd_wm_application_get_active_window(app));
+ g_debug("found already running returning app_name=%s app_exec=%s \
app_info=%x\n", + item->name, item_exec_name, app_info);
+
+ g_free(exec_name);
+ g_free(item_exec_name);
+
+ return app_info;
+ }
+
+ g_free(exec_name);
+ g_free(item_exec_name);
+
+ }
+
+ g_print("could not find match for app=%s\n", item->name);
+
+ return NULL;
+}
+
+
+//Called to launch the application
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic