+typedef struct {
+ GtkWidget *dialog;
+ GtkWidget *entry;
+} SendLogoDialog;
+static SendLogoDialog sendLogoDialog = {NULL, NULL};
+
+static void OkSendLogoDialog(GtkWidget *w, gpointer gtkdata)
+{
+ GSM_SMSMessage SMS;
+ GSM_Error error;
+
+ char Data[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ PhoneEvent *e = (PhoneEvent *)g_malloc(sizeof(PhoneEvent));
+ D_SMSMessage *data = (D_SMSMessage *)g_malloc(sizeof(D_SMSMessage));
+ char *number = gtk_entry_get_text(GTK_ENTRY(sendLogoDialog.entry));
+ char *operator = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(networkCombo)->entry));
+ char *opcode = GSM_GetNetworkCode(operator);
+ int i;
+
+ int current=0;
+
+ /* Default settings for SMS message:
+ - no delivery report
+ - Class Message 1
+ - no compression
+ - 8 bit data
+ - SMSC no. 1
+ - validity 3 days
+ - set UserDataHeaderIndicator
+ */
+
+ SMS.Type = GST_MO;
+ SMS.Class = 1;
+ SMS.Compression = false;
+ SMS.EightBit = true;
+ SMS.MessageCenter = xgnokiiConfig.smsSetting[0]; /* we need to at least set .Format ! */
+ SMS.MessageCenter.No = 0;
+ SMS.Validity = 4320; /* 4320 minutes == 72 hours */
+ SMS_SetupUDH(&SMS,bitmap.type);
+
+ /* prepare data */
+
+ switch (bitmap.type) {
+
+ case GSM_CallerLogo:
+ /* below condition must be there, because if you launch logos before
+ * callerGroups are available, you will see segfault - callerGroups not initialized
+ */
+ if (phoneMonitor.supported & PM_CALLERGROUP) {
+ for (i = 0;i < 6;i++)
+ if (strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(callerCombo)->entry)),
+ xgnokiiConfig.callerGroups[i]) == 0) bitmap.number = i;
+ }
+ break;
+
+ case GSM_OperatorLogo:
+ opcode=GSM_GetNetworkCode(operator);
+ Data[current++] = ((opcode[1] & 0x0f) << 4) | (opcode[0] & 0xf);
+ Data[current++] = 0xf0 | (opcode[2] & 0x0f);
+ Data[current++] = ((opcode[5] & 0x0f) << 4) | (opcode[4] & 0xf);
+ break;
+
+ default: /* unsupported */
+ g_free(e);
+ g_free(data);
+ return;
+ }
+
+ strncpy(SMS.Destination,number,sizeof(SMS.Destination));
+ SMS.Destination[sizeof(SMS.Destination)-1]='\0';
+
+ /* Set the logo size */
+ current++;
+ Data[current++] = bitmap.width;
+ Data[current++] = bitmap.height;
+
+ Data[current++] = 0x01;
+
+ memcpy(SMS.MessageText,Data,current);
+ memcpy(SMS.MessageText+current,bitmap.bitmap,bitmap.size);
+ SMS.MessageTextLength = current+bitmap.size;
+
+ data->sms = &SMS;
+ e->event = Event_SendSMSMessage;
+ e->data = data;
+
+ /* launch event and wait for result */
+ GUI_InsertEvent(e);
+ pthread_mutex_lock (&sendSMSMutex);
+ pthread_cond_wait (&sendSMSCond, &sendSMSMutex);
+ pthread_mutex_unlock (&sendSMSMutex);
+ error = data->status;
+ g_free(data);
+
+ /* watch for errors */
+ if (error != GE_SMSSENDOK) {
+ gchar *buf = g_strdup_printf(_("Error sending bitmap\n(error=%d)"),error);
+ gtk_label_set_text(GTK_LABEL(errorDialog.text),buf);
+ gtk_widget_show(errorDialog.dialog);
+ g_free(buf);
+ }
+
+ gtk_widget_hide (((SendLogoDialog *) gtkdata)->dialog);
+}
+
+/* Here would be appropriate xgnokii_sms/ShowSelectContactsDialog()
+ * (and the multi-recipient handling code).
+ * I haven't implemented yet any such code as the whole XGnokii has broken
+ * design of hand-coded GTK+ GUI (even w/o any Gnome features) instead of Glade.
+ * The right solution is to drop 95% of XGNokii code, not to write yet another
+ * insane +2% of hand-coded GUI code.
+ */
+void SendLogoEvent(GtkWidget *widget)
+{
+ if (sendLogoDialog.dialog == NULL)
+ {
+ GtkWidget *button, *label;
+
+ sendLogoDialog.dialog = gtk_dialog_new ();
+ gtk_window_set_title (GTK_WINDOW (sendLogoDialog.dialog), _("Send logo"));
+ gtk_window_set_modal(GTK_WINDOW (sendLogoDialog.dialog), TRUE);
+ gtk_container_set_border_width (GTK_CONTAINER (sendLogoDialog.dialog), 10);
+ gtk_signal_connect (GTK_OBJECT (sendLogoDialog.dialog), "delete_event",
+ GTK_SIGNAL_FUNC (DeleteEvent), NULL);
+
+ button = gtk_button_new_with_label (_("Send"));
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->action_area),
+ button, TRUE, TRUE, 10);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (OkSendLogoDialog), (gpointer) &sendLogoDialog);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default (button);
+ gtk_widget_show (button);
+
+ button = gtk_button_new_with_label (_("Cancel"));
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->action_area),
+ button, TRUE, TRUE, 10);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (CancelDialog), (gpointer) sendLogoDialog.dialog);
+ gtk_widget_show (button);
+
+ gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (sendLogoDialog.dialog)->vbox), 5);
+
+ label = gtk_label_new (_("Number:"));
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->vbox), label, FALSE, FALSE, 5);
+ gtk_widget_show (label);
+
+ sendLogoDialog.entry = gtk_entry_new_with_max_length (GSM_MAX_PHONEBOOK_NUMBER_LENGTH);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->vbox), sendLogoDialog.entry, FALSE, FALSE, 5);
+ gtk_widget_show (sendLogoDialog.entry);
+ }
+
+ gtk_entry_set_text (GTK_ENTRY (sendLogoDialog.entry), "");
+
+ gtk_widget_show (sendLogoDialog.dialog);
+}
+