diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_contacts.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk_contacts.c | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_contacts.c b/src/conversation/gnunet-conversation-gtk_contacts.c index 531d5256..78fb96e3 100644 --- a/src/conversation/gnunet-conversation-gtk_contacts.c +++ b/src/conversation/gnunet-conversation-gtk_contacts.c | |||
@@ -28,6 +28,7 @@ | |||
28 | */ | 28 | */ |
29 | #include "gnunet-conversation-gtk.h" | 29 | #include "gnunet-conversation-gtk.h" |
30 | #include "gnunet-conversation-gtk_contacts.h" | 30 | #include "gnunet-conversation-gtk_contacts.h" |
31 | #include "gnunet-conversation-gtk_get_label.h" | ||
31 | #include "gnunet-conversation-gtk_phone.h" | 32 | #include "gnunet-conversation-gtk_phone.h" |
32 | #include "gnunet-conversation-gtk_zones.h" | 33 | #include "gnunet-conversation-gtk_zones.h" |
33 | 34 | ||
@@ -276,6 +277,66 @@ gnunet_conversation_gtk_contacts_zone_combobox_changed_cb (GtkComboBox *widget, | |||
276 | 277 | ||
277 | 278 | ||
278 | /** | 279 | /** |
280 | * User clicked the "paste" button. Handle data from the clipboard, | ||
281 | * if it is a "gnunet://gns/"-URI, import it into our current zone / | ||
282 | * address book. | ||
283 | * | ||
284 | * @param clipboard the clipboard | ||
285 | * @param text the text from the board | ||
286 | * @param user_data NULL | ||
287 | */ | ||
288 | static void | ||
289 | handle_paste_data (GtkClipboard *clipboard, | ||
290 | const gchar *text, | ||
291 | gpointer data) | ||
292 | { | ||
293 | char *name; | ||
294 | char *slash; | ||
295 | const char *label; | ||
296 | |||
297 | if (NULL == text) | ||
298 | return; /* clipboard empty */ | ||
299 | if (0 != strncasecmp ("gnunet://gns/", | ||
300 | text, | ||
301 | strlen ("gnunet://gns/"))) | ||
302 | { | ||
303 | GCG_log (_("Invalid URI `%s'\n"), | ||
304 | text); | ||
305 | return; | ||
306 | } | ||
307 | name = GNUNET_strdup (&text[strlen ("gnunet://gns/")]); | ||
308 | slash = strchr (name, '/'); | ||
309 | if ( (NULL != slash) && | ||
310 | ('\0' != slash[1]) ) | ||
311 | { | ||
312 | *slash = '\0'; | ||
313 | label = &slash[1]; | ||
314 | if (GNUNET_OK != | ||
315 | GNUNET_DNSPARSER_check_label (label)) | ||
316 | { | ||
317 | GCG_log (_("Invalid label `%s' in URI `%s'\n"), | ||
318 | label, | ||
319 | text); | ||
320 | GNUNET_free (name); | ||
321 | return; | ||
322 | } | ||
323 | else | ||
324 | { | ||
325 | /* got a label already, try to use it */ | ||
326 | GSC_get_label_for_name (name, | ||
327 | label); | ||
328 | GNUNET_free (name); | ||
329 | return; | ||
330 | } | ||
331 | } | ||
332 | /* don't have a label yet, need to prompt! */ | ||
333 | GSC_get_label_for_name (name, | ||
334 | NULL); | ||
335 | GNUNET_free (name); | ||
336 | } | ||
337 | |||
338 | |||
339 | /** | ||
279 | * User clicked the "paste" button. Copy address information | 340 | * User clicked the "paste" button. Copy address information |
280 | * from the clipboard into our current zone / address book. | 341 | * from the clipboard into our current zone / address book. |
281 | * | 342 | * |
@@ -286,7 +347,13 @@ void | |||
286 | gnunet_conversation_gtk_contacts_paste_button_clicked_cb (GtkButton *button, | 347 | gnunet_conversation_gtk_contacts_paste_button_clicked_cb (GtkButton *button, |
287 | gpointer user_data) | 348 | gpointer user_data) |
288 | { | 349 | { |
289 | GNUNET_break (0); // FIXME: not implemented | 350 | GtkClipboard *cb; |
351 | |||
352 | |||
353 | cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); | ||
354 | gtk_clipboard_request_text (cb, | ||
355 | &handle_paste_data, | ||
356 | NULL); | ||
290 | } | 357 | } |
291 | 358 | ||
292 | 359 | ||