Changeset 3321
- Timestamp:
- 11/01/07 17:36:13 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2/applications/openmoko-dialer2
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
src/dialer/dialer-main.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
r3318 r3321 1 2007-11-01 Thomas Wood <thomas@openedhand.com> 2 3 * src/dialer/dialer-main.c: Use dbus service to initiate calls 4 1 5 2007-11-01 Thomas Wood <thomas@openedhand.com> 2 6 -
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer/dialer-main.c
r3312 r3321 25 25 // #include "moko-dialer.h" 26 26 #include "moko-keypad.h" 27 #include "moko-history.h" 27 28 28 static gboolean show_dialer;29 29 static gboolean show_missed; 30 static gchar *number = NULL;31 30 32 31 static GOptionEntry entries[] = { 33 {"show-dialer", 's', 0, G_OPTION_ARG_NONE, &show_dialer,34 "Show the dialer at startup", "N"},35 32 36 33 {"show-missed", 'm', 0, G_OPTION_ARG_NONE, &show_missed, 37 34 "Show the history window filtered by the missed, none.", "N"}, 38 39 {"dial", 'd', 0, G_OPTION_ARG_STRING, &number,40 "Dial the specified number.", "N"},41 35 42 36 {NULL} … … 44 38 45 39 /* Callbacks from widgets */ 46 #if 047 40 48 41 static void 49 42 on_keypad_dial_clicked (MokoKeypad *keypad, 50 43 const gchar *number, 51 MokoDialer *dialer)44 DBusGProxy *proxy) 52 45 { 53 GtkWidget *dlg; 54 MokoDialerPrivate *priv; 55 MokoContactEntry *entry = NULL; 56 57 g_return_if_fail (MOKO_IS_DIALER (dialer)); 58 priv = dialer->priv; 46 GError *error = NULL; 59 47 60 if (!number) { 48 if (!number) 49 { 50 /* 61 51 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 1); 62 52 moko_history_set_filter (MOKO_HISTORY (priv->history), HISTORY_FILTER_DIALED); 53 */ 63 54 return; 64 55 } 65 56 66 /* check current dialer state */ 67 if (0 || priv->status != DIALER_STATUS_NORMAL) 57 g_debug ("Dial %s", number); 58 59 dbus_g_proxy_call (proxy, "Dial", &error, G_TYPE_STRING, number, G_TYPE_INVALID, G_TYPE_INVALID); 60 61 if (error) 68 62 { 69 gchar *strings[] = { 70 "Normal", 71 "Incoming Call", 72 "Dialing", 73 "Outgoing Call" 74 }; 75 dlg = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, 76 "Cannot dial when dialer is busy.\nCurrent status = %s", strings[priv->status]); 77 gtk_dialog_run (GTK_DIALOG (dlg)); 78 gtk_widget_destroy (dlg); 79 80 g_warning ("Cannot dial when dialer is busy: %d\n", priv->status); 81 82 return; 63 g_warning (error->message); 83 64 } 84 priv->status = DIALER_STATUS_DIALING; 85 86 /* check for network connection */ 87 if (priv->registered != MOKO_GSMD_CONNECTION_NETREG_HOME 88 && priv->registered != MOKO_GSMD_CONNECTION_NETREG_ROAMING 89 && priv->registered != MOKO_GSMD_CONNECTION_NETREG_DENIED) 65 else 90 66 { 91 gchar *strings[] = { 92 "None", 93 "Home network registered", 94 "Searching for network", 95 "Network registration denied", 96 "", 97 "Roaming network registered" 98 }; 99 100 dlg = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, 101 "Cannot dial number. %s", strings[priv->registered]); 102 gtk_dialog_run (GTK_DIALOG (dlg)); 103 gtk_widget_destroy (dlg); 104 105 /* no point continuing if we're not connected to a network! */ 106 priv->status = DIALER_STATUS_NORMAL; 107 return; 67 /* the dbus object takes over now */ 68 gtk_main_quit(); 108 69 } 109 110 entry = moko_contacts_lookup (moko_contacts_get_default (), number);111 112 /* Prepare a voice journal entry */113 if (priv->journal)114 {115 priv->entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY);116 moko_journal_entry_set_direction (priv->entry, DIRECTION_OUT);117 moko_journal_entry_set_source (priv->entry, "Openmoko Dialer");118 moko_journal_entry_set_gsm_location (priv->entry, &priv->gsm_location);119 moko_journal_voice_info_set_distant_number (priv->entry, number);120 if (entry && entry->contact->uid)121 moko_journal_entry_set_contact_uid (priv->entry, entry->contact->uid);122 }123 moko_talking_outgoing_call (MOKO_TALKING (priv->talking), number, entry);124 125 gtk_notebook_insert_page (GTK_NOTEBOOK (priv->notebook), priv->talking,126 gtk_image_new_from_file (PKGDATADIR"/phone.png"),127 0);128 gtk_container_child_set (GTK_CONTAINER (priv->notebook), priv->talking,129 "tab-expand", TRUE,130 NULL);131 132 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);133 134 gtk_window_present (GTK_WINDOW (priv->window));135 136 moko_keypad_set_talking (MOKO_KEYPAD (priv->keypad), TRUE);137 138 moko_gsmd_connection_voice_dial (priv->connection, number);139 140 g_signal_emit (G_OBJECT (dialer), dialer_signals[OUTGOING_CALL], 0, number);141 70 } 142 71 … … 144 73 on_history_dial_number (MokoHistory *history, 145 74 const gchar *number, 146 MokoDialer *dialer)75 DBusGProxy *proxy) 147 76 { 148 on_keypad_dial_clicked (NULL, number, dialer);77 on_keypad_dial_clicked (NULL, number, proxy); 149 78 } 150 79 151 152 #endif153 80 int main (int argc, char **argv) 154 81 { 82 GtkWidget *window, *notebook, *keypad, *history; 83 MokoJournal *journal; 155 84 156 85 if (argc != 1) … … 173 102 174 103 104 DBusGConnection *connection; 105 GError *error; 106 DBusGProxy *proxy; 107 108 g_type_init (); 109 110 error = NULL; 111 connection = dbus_g_bus_get (DBUS_BUS_SESSION, 112 &error); 113 if (connection == NULL) 114 { 115 g_printerr ("Failed to open connection to bus: %s\n", 116 error->message); 117 g_error_free (error); 118 exit (1); 119 } 120 121 proxy = dbus_g_proxy_new_for_name (connection, "org.openmoko.Dialer", "/org/openmoko/Dialer", "org.openmoko.Dialer"); 122 175 123 /* application object */ 176 124 g_set_application_name ("OpenMoko Dialer"); 177 #if 0 125 126 /* Set up the journal */ 127 journal = moko_journal_open_default (); 128 if (!journal || !moko_journal_load_from_storage (journal)) 129 { 130 g_warning ("Could not load journal"); 131 journal = NULL; 132 } 133 134 135 window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 136 g_signal_connect (G_OBJECT (window), "delete-event", 137 (GCallback) gtk_widget_hide_on_delete, NULL); 138 gtk_window_set_title (GTK_WINDOW (window), "Dialer"); 139 140 /* Notebook */ 141 notebook = gtk_notebook_new (); 142 gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_BOTTOM); 143 gtk_container_add (GTK_CONTAINER (window), notebook); 144 145 146 /* Keypad */ 147 keypad = moko_keypad_new (); 148 g_signal_connect (keypad, "dial_number", G_CALLBACK (on_keypad_dial_clicked), proxy); 149 150 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), keypad, gtk_image_new_from_file (PKGDATADIR"/dtmf.png")); 151 gtk_container_child_set (GTK_CONTAINER (notebook), keypad, "tab-expand", TRUE, NULL); 152 153 /* History */ 154 history = moko_history_new (journal); 155 g_signal_connect (history, "dial_number", G_CALLBACK (on_history_dial_number), proxy); 156 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), history, 157 gtk_image_new_from_stock (MOKO_STOCK_CALL_HISTORY, 158 GTK_ICON_SIZE_BUTTON)); 159 gtk_container_child_set (GTK_CONTAINER (notebook), history, 160 "tab-expand", TRUE, 161 NULL); 162 163 gtk_widget_show_all (window); 178 164 if (show_missed) 179 moko_dialer_show_missed_calls (dialer, NULL);180 else if (show_dialer)181 moko_dialer_show_dialer (dialer, NULL);182 #endif 165 gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 1); 166 else 167 gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0); 168 183 169 gtk_main (); 184 170
Note: See TracChangeset
for help on using the changeset viewer.
