📄 max.c
字号:
/* * sending sms to the austrian gsm provider max.mobil * through e-mail -> smtp has to be enabled in the * preferences dialog * * Authors: Michael Jochum <e9725005@stud3.tuwien.ac.at> * * TODO: * * Fixes: * * For license terms, see the file COPYING in the project directory. */#include <string.h>#include <glib.h>#include <gnome.h>#include <gsms-plugin.h>gint init_plugin (PluginData *pd);static void destroy_plugin (PluginData *pd);static gint send_sms(PluginData *pd, gchar * text, gchar * tel); void configuration_dialog(PluginData *pd, gpointer parent);static gint configure_dlg_clicked_cb(GnomeDialog *dialog, gint button, gpointer user_data);static gint send_sms(PluginData *pd, gchar * text, gchar * tel){ gchar *email, *pin; gint res; pin = gsms_plugin_config_load(pd); if(pin == NULL || *pin=='\0') pin = g_strdup("no pin"); email = g_strdup_printf("%s@max.mail.at", tel); if ((res = gsms_send_mail(email, pin, text)) < 0) g_log(NULL, G_LOG_LEVEL_WARNING, _("Could not send mail to max.mail.at")); g_free(email); g_free(pin); return res < 0 ? -1 : 0;}voiddestroy_plugin (PluginData *pd){ g_free(pd->networks->data);}static gint configure_dlg_clicked_cb(GnomeDialog *dialog, gint button, gpointer entry){ gchar *pin; if(button == 0) { /* if OK is pressed */ pin = gtk_entry_get_text(GTK_ENTRY(entry)); if(pin != NULL) gsms_plugin_config_save( gtk_object_get_user_data(GTK_OBJECT(entry)), pin); } return TRUE;}voidconfiguration_dialog(PluginData *pd, gpointer parent){ GtkWidget *dialog, *vbox, *hbox, *label, *entry; gchar *pin; dialog = gnome_dialog_new(_("Max.Mobil (Austria)"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW(parent)); vbox = GNOME_DIALOG (dialog)->vbox; label = gtk_label_new(_( "To send messages to max.mobil you must obtain a\n" "PIN-Code. The best way to do this is sending a\n" "message trough this plugin and wait for the response.\n" "Detailed instructions and the PIN-Code are included\n" "in the mail.")); gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); gtk_widget_show(GTK_WIDGET(label)); hbox = gtk_hbox_new(FALSE, 5); label = gtk_label_new(_("Max.Mobil PIN-Code: ")); entry = gtk_entry_new(); pin = gsms_plugin_config_load(pd); if(pin != NULL) gtk_entry_set_text(GTK_ENTRY(entry), pin); g_free(pin); gtk_object_set_user_data(GTK_OBJECT(entry), pd); gtk_signal_connect(GTK_OBJECT(dialog), "clicked", GTK_SIGNAL_FUNC(configure_dlg_clicked_cb), entry); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show_all(GTK_WIDGET(hbox)); gnome_dialog_run_and_close (GNOME_DIALOG (dialog));}gintinit_plugin (PluginData *pd){ GSMNetwork *network; /* initialize */ pd->name = "max.mail.at (needs email)"; pd->authors = "Michael Jochum <e9725005@student.tuwien.ac.at>"; pd->destroy_plugin = destroy_plugin; pd->send_sms = send_sms; pd->configuration_dialog = configuration_dialog; network = g_new(GSMNetwork, 1); network->prefix = "+43676"; network->name = "Max.Mobil"; pd->default_priority = 200; pd->networks = g_slist_append(pd->networks, network); return PLUGIN_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -