Mercurial > audlegacy
annotate Plugins/General/scrobbler/configure.c @ 1637:5261e37b4d55 trunk
[svn] - fully working CoreAudio plugin, based on the OSS plugin and an incomplete xmms coreaudio plugin (fink)
author | nenolod |
---|---|
date | Thu, 07 Sep 2006 11:32:59 -0700 |
parents | 84169cc8cb2d |
children | a8f3d8db01a2 |
rev | line source |
---|---|
694 | 1 #ifdef HAVE_CONFIG_H |
2 # include <config.h> | |
3 #endif | |
4 | |
695 | 5 #include "libaudacious/util.h" |
6 #include "libaudacious/configdb.h" | |
7 | |
694 | 8 #include <sys/types.h> |
9 #include <sys/stat.h> | |
10 #include <unistd.h> | |
11 #include <string.h> | |
12 #include <stdio.h> | |
13 | |
695 | 14 #include "md5.h" |
15 | |
694 | 16 #include <glib.h> |
17 #include <glib/gi18n.h> | |
18 | |
19 #include <gdk/gdkkeysyms.h> | |
20 #include <gtk/gtk.h> | |
21 | |
22 #include "configure.h" | |
23 | |
695 | 24 GtkWidget *entry1, *entry2, *cfgdlg; |
25 | |
26 static char *hexify(char *pass, int len) | |
27 { | |
28 static char buf[33]; | |
29 char *bp = buf; | |
30 char hexchars[] = "0123456789abcdef"; | |
31 int i; | |
32 | |
33 memset(buf, 0, sizeof(buf)); | |
34 | |
35 for(i = 0; i < len; i++) { | |
36 *(bp++) = hexchars[(pass[i] >> 4) & 0x0f]; | |
37 *(bp++) = hexchars[pass[i] & 0x0f]; | |
38 } | |
39 *bp = 0; | |
40 return buf; | |
41 } | |
42 | |
700
99382cddf771
[svn] Fixes for all warnings (except 3 spurious GCC 4.0 ones, upgrade to 4.1 if you see them) and a performance increase. By external contributor Diego "FlameEyes" Petteno (Gentoo).
chainsaw
parents:
698
diff
changeset
|
43 static void saveconfig(GtkWidget *wid __attribute__((unused)), gpointer data) |
695 | 44 { |
45 ConfigDb *cfgfile; | |
46 | |
47 const char *uid = gtk_entry_get_text(GTK_ENTRY(entry1)); | |
48 const char *pwd = gtk_entry_get_text(GTK_ENTRY(entry2)); | |
49 | |
50 if ((cfgfile = bmp_cfg_db_open())) | |
51 { | |
52 md5_state_t md5state; | |
53 unsigned char md5pword[16]; | |
54 | |
55 bmp_cfg_db_set_string(cfgfile, "audioscrobbler", "username", (char *)uid); | |
56 | |
57 if (pwd != NULL && pwd[0] != '\0') | |
58 { | |
59 md5_init(&md5state); | |
60 md5_append(&md5state, (unsigned const char *)pwd, strlen(pwd)); | |
61 md5_finish(&md5state, md5pword); | |
62 bmp_cfg_db_set_string(cfgfile, "audioscrobbler", "password", | |
700
99382cddf771
[svn] Fixes for all warnings (except 3 spurious GCC 4.0 ones, upgrade to 4.1 if you see them) and a performance increase. By external contributor Diego "FlameEyes" Petteno (Gentoo).
chainsaw
parents:
698
diff
changeset
|
63 hexify((char*)md5pword, sizeof(md5pword))); |
695 | 64 } |
65 bmp_cfg_db_close(cfgfile); | |
66 } | |
67 } | |
68 | |
69 /* Generated by glade, sorta. */ | |
70 GtkWidget * | |
71 create_cfgdlg(void) | |
694 | 72 { |
1176 | 73 ConfigDb *db; |
694 | 74 GtkWidget *vbox2; |
75 GtkWidget *table1; | |
76 GtkWidget *label3; | |
77 GtkWidget *label1; | |
78 GtkWidget *label2; | |
1190 | 79 GtkWidget *himage1; |
80 GtkWidget *align1; | |
694 | 81 |
82 vbox2 = gtk_vbox_new (FALSE, 0); | |
83 | |
1190 | 84 label1 = gtk_label_new (_("<b>Scrobbler Preferences</b>")); |
85 gtk_widget_show (label1); | |
86 gtk_label_set_use_markup (GTK_LABEL (label1), TRUE); | |
87 gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5); | |
88 | |
89 gtk_box_pack_start (GTK_BOX (vbox2), label1, FALSE, FALSE, 0); | |
90 | |
91 align1 = gtk_alignment_new(0, 0, 0, 0); | |
92 gtk_widget_show (align1); | |
93 gtk_alignment_set_padding(GTK_ALIGNMENT(align1), 0, 0, 12, 0); | |
694 | 94 |
1190 | 95 table1 = gtk_table_new (2, 2, FALSE); |
96 gtk_widget_show (table1); | |
97 gtk_container_add(GTK_CONTAINER(align1), table1); | |
98 gtk_box_pack_start (GTK_BOX (vbox2), align1, TRUE, TRUE, 0); | |
99 gtk_table_set_row_spacings (GTK_TABLE(table1), 6); | |
100 gtk_table_set_col_spacings (GTK_TABLE(table1), 6); | |
101 | |
102 label2 = gtk_label_new (_("Username:")); | |
103 gtk_widget_show (label2); | |
104 gtk_table_attach_defaults (GTK_TABLE (table1), label2, 0, 1, 2, 3); | |
105 gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_RIGHT); | |
106 gtk_misc_set_alignment (GTK_MISC (label2), 1, 0.5); | |
694 | 107 |
108 label3 = gtk_label_new (_("Password:")); | |
109 gtk_widget_show (label3); | |
110 gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 3, 4, | |
111 (GtkAttachOptions) (GTK_FILL), | |
112 (GtkAttachOptions) (0), 0, 0); | |
113 gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_RIGHT); | |
114 gtk_misc_set_alignment (GTK_MISC (label3), 1, 0.5); | |
115 | |
116 entry1 = gtk_entry_new (); | |
117 gtk_widget_show (entry1); | |
1190 | 118 gtk_table_attach_defaults (GTK_TABLE (table1), entry1, 1, 2, 2, 3); |
694 | 119 |
1190 | 120 entry2 = gtk_entry_new (); |
121 gtk_widget_show (entry2); | |
122 gtk_table_attach_defaults (GTK_TABLE (table1), entry2, 1, 2, 3, 4); | |
123 g_signal_connect(entry2, "changed", (GCallback) saveconfig, NULL); | |
694 | 124 |
1190 | 125 himage1 = gtk_image_new_from_file (DATA_DIR "/images/audioscrobbler_badge.png"); |
126 gtk_widget_show (himage1); | |
127 gtk_box_pack_start (GTK_BOX (vbox2), himage1, FALSE, FALSE, 0); | |
128 gtk_misc_set_alignment (GTK_MISC (himage1), 1, 0.5); | |
694 | 129 |
1176 | 130 gtk_entry_set_text(GTK_ENTRY(entry1), ""); |
131 gtk_entry_set_text(GTK_ENTRY(entry2), ""); | |
132 | |
133 if ((db = bmp_cfg_db_open())) { | |
134 gchar *username = NULL; | |
135 bmp_cfg_db_get_string(db, "audioscrobbler", "username", | |
136 &username); | |
137 if (username) { | |
138 gtk_entry_set_text(GTK_ENTRY(entry1), username); | |
139 g_free(username); | |
140 } | |
141 bmp_cfg_db_close(db); | |
142 } | |
143 | |
1181 | 144 return vbox2; |
694 | 145 } |
146 |