Released under the terms of the GNU GPL, see file COPYING for more details.
$Log$
- Revision 1.1.1.1 2001/11/25 21:59:31 short
- :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
+ Revision 1.1.1.5 2002/04/03 00:08:33 short
+ Found in "gnokii-working" directory, some November-patches version
Revision 1.9 2001/09/14 12:53:00 pkot
New preview logos.
#include "xpm/New.xpm"
#include "xpm/Send.xpm"
+#include "xpm/SendSMS.xpm"
#include "xpm/Read.xpm"
#include "xpm/Open.xpm"
#include "xpm/Save.xpm"
#include "xpm/Tool_filled_rectangle.xpm"
extern GSM_Network GSM_Networks[];
-extern GSM_Statemachine statemachine;
+extern GSM_Statemachine xgnokii_statemachine; /* from xgnokii_lowlevel.c */
GtkWidget *GUI_LogosWindow;
}
}
+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);
+}
+
static void ClearLogoEvent(GtkWidget *widget) {
// bitmap.size=bitmap.width*bitmap.height/8;
if (GTK_TOGGLE_BUTTON(buttonStartup)->active) {
/* look for old bitmap type, clean if another */
clear = 1;
- GSM_ResizeBitmap(&bitmap,GSM_StartupLogo, &statemachine.Phone.Info);
+ GSM_ResizeBitmap(&bitmap,GSM_StartupLogo, &xgnokii_statemachine.Phone.Info);
}
/* has phone support for callerGroups? */
/* previous was startup? clear and draw batteries, signal, ... */
/* Clear anyway for 7110...CK */
clear = 1;
- GSM_ResizeBitmap(&bitmap,GSM_CallerLogo, &statemachine.Phone.Info);
+ GSM_ResizeBitmap(&bitmap,GSM_CallerLogo, &xgnokii_statemachine.Phone.Info);
}
}
/* previous startup? clear and draw batteries, signal, ... */
/* Clear anyway for 7110..CK */
clear = 1;
- GSM_ResizeBitmap(&bitmap,GSM_OperatorLogo, &statemachine.Phone.Info);
+ GSM_ResizeBitmap(&bitmap,GSM_OperatorLogo, &xgnokii_statemachine.Phone.Info);
}
/* must clear? */
{ NULL, "<control>G", GetNetworkInfoEvent, 0, NULL},
{ NULL, NULL, GetLogoEvent, 0, NULL},
{ NULL, "<control>T", SetLogoEvent, 0, NULL},
+ { NULL, "<control>N", SendLogoEvent, 0, NULL},
{ NULL, NULL, NULL, 0, "<Separator>"},
{ NULL, "<control>W", CloseLogosWindow, 0, NULL},
{ NULL, NULL, NULL, 0, "<Branch>"},
logosMenuItems[5].path = g_strdup(_("/File/_Get operator"));
logosMenuItems[6].path = g_strdup(_("/File/Get _logo"));
logosMenuItems[7].path = g_strdup(_("/File/Se_t logo"));
- logosMenuItems[8].path = g_strdup(_("/File/Sep2"));
- logosMenuItems[9].path = g_strdup(_("/File/_Close"));
- logosMenuItems[10].path = g_strdup(_("/_Edit"));
- logosMenuItems[11].path = g_strdup(_("/Edit/_Clear"));
- logosMenuItems[12].path = g_strdup(_("/Edit/_Invert"));
- logosMenuItems[13].path = g_strdup(_("/Edit/Sep3"));
- logosMenuItems[14].path = g_strdup(_("/Edit/_Up logo"));
- logosMenuItems[15].path = g_strdup(_("/Edit/_Down logo"));
- logosMenuItems[16].path = g_strdup(_("/Edit/_Left logo"));
- logosMenuItems[17].path = g_strdup(_("/Edit/_Right logo"));
- logosMenuItems[18].path = g_strdup(_("/Edit/Sep4"));
- logosMenuItems[19].path = g_strdup(_("/Edit/Flip _horizontal"));
- logosMenuItems[20].path = g_strdup(_("/Edit/Flip _vertical"));
+ logosMenuItems[8].path = g_strdup(_("/File/Se_nd logo"));
+ logosMenuItems[9].path = g_strdup(_("/File/Sep2"));
+ logosMenuItems[10].path = g_strdup(_("/File/_Close"));
+ logosMenuItems[11].path = g_strdup(_("/_Edit"));
+ logosMenuItems[12].path = g_strdup(_("/Edit/_Clear"));
+ logosMenuItems[13].path = g_strdup(_("/Edit/_Invert"));
+ logosMenuItems[14].path = g_strdup(_("/Edit/Sep3"));
+ logosMenuItems[15].path = g_strdup(_("/Edit/_Up logo"));
+ logosMenuItems[16].path = g_strdup(_("/Edit/_Down logo"));
+ logosMenuItems[17].path = g_strdup(_("/Edit/_Left logo"));
+ logosMenuItems[18].path = g_strdup(_("/Edit/_Right logo"));
+ logosMenuItems[19].path = g_strdup(_("/Edit/Sep4"));
+ logosMenuItems[20].path = g_strdup(_("/Edit/Flip _horizontal"));
+ logosMenuItems[21].path = g_strdup(_("/Edit/Flip _vertical"));
}
void GUI_CreateLogosWindow (void) {
&GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]),
(GtkSignalFunc)SetLogoEvent, toolBar);
+ gtk_toolbar_append_item(GTK_TOOLBAR(toolBar), NULL, _("Send logo"), NULL,
+ NewPixmap(SendSMS_xpm, GUI_LogosWindow->window,
+ &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]),
+ (GtkSignalFunc)SendLogoEvent, toolBar);
+
gtk_toolbar_append_space(GTK_TOOLBAR(toolBar));
gtk_toolbar_append_item (GTK_TOOLBAR (toolBar), NULL, _("Import from file"), NULL,