Changeset 2811
- Timestamp:
- 08/23/07 15:14:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c
r2342 r2811 42 42 } 43 43 44 45 static DBusGConnection * 46 dbus_setup(gboolean *p_already_running) 47 { 48 DBusGConnection *connection; 49 DBusGProxy *proxy; 50 GError *error = NULL; 51 guint32 ret; 52 53 if (p_already_running) 54 *p_already_running = FALSE; 55 56 connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); 57 if (connection == NULL) 58 { 59 g_warning ("Failed to make a connection to the session bus: %s", 60 error->message); 61 g_error_free (error); 62 return NULL; 63 } 64 65 proxy = dbus_g_proxy_new_for_name (connection, 66 DBUS_SERVICE_DBUS, 67 DBUS_PATH_DBUS, 68 DBUS_INTERFACE_DBUS); 69 if (proxy == NULL) 70 { 71 g_warning ("Error getting a DBus Proxy\n"); 72 dbus_g_connection_unref (connection); 73 return NULL; 74 } 75 76 if (!org_freedesktop_DBus_request_name (proxy, 77 DIALER_NAMESPACE, 78 0, &ret, &error)) 79 { 80 /* Error requesting the name */ 81 g_warning ("There was an error requesting the name: %s\n",error->message); 82 g_error_free (error); 83 84 dbus_g_connection_unref (connection); 85 86 return NULL; 87 } 88 if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) 89 { 90 if (p_already_running) 91 *p_already_running = TRUE; 92 } 93 94 return connection; 95 } 96 97 44 98 static void 45 99 _show_dialer (DBusGConnection *conn) … … 100 154 MokoDialer *dialer; 101 155 DBusGConnection *connection; 102 DBusGProxy *proxy; 103 GError *error = NULL; 104 guint32 ret; 156 gboolean already_running; 105 157 106 158 if (argc != 1) … … 122 174 123 175 /* Try and setup our DBus service */ 124 connection = dbus_ g_bus_get (DBUS_BUS_SESSION, &error);176 connection = dbus_setup(&already_running); 125 177 if (connection == NULL) 126 178 { 127 g_warning ("Failed to make a connection to the session bus: %s", 128 error->message); 129 g_error_free (error); 130 } 131 proxy = dbus_g_proxy_new_for_name (connection, 132 DBUS_SERVICE_DBUS, 133 DBUS_PATH_DBUS, 134 DBUS_INTERFACE_DBUS); 135 if (!org_freedesktop_DBus_request_name (proxy, 136 DIALER_NAMESPACE, 137 0, &ret, &error)) 138 { 139 /* Error requesting the name */ 140 g_warning ("There was an error requesting the name: %s\n",error->message); 141 g_error_free (error); 142 143 gdk_init(&argc, &argv); 144 gdk_notify_startup_complete (); 145 146 return 1; 147 } 148 if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) 179 /* 180 * If no dbus, we can't get a remote signal to show 181 * the dialer, so just show it immediately 182 */ 183 show_dialer = TRUE; 184 } 185 186 if (already_running) 149 187 { 150 188 /* Someone else hase registere dthe object */
Note: See TracChangeset
for help on using the changeset viewer.
