]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-contact-menu.c
individual-widget: display channels list if available
[empathy.git] / libempathy-gtk / empathy-contact-menu.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2008 Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * Authors: Xavier Claessens <xclaesse@gmail.com>
20  */
21
22 #include "config.h"
23
24 #include <string.h>
25
26 #include <glib/gi18n-lib.h>
27 #include <gtk/gtk.h>
28 #include <telepathy-logger/log-manager.h>
29
30 #include <libempathy/empathy-contact-manager.h>
31 #include <libempathy/empathy-request-util.h>
32 #include <libempathy/empathy-utils.h>
33 #include <libempathy/empathy-chatroom-manager.h>
34 #include <libempathy/empathy-contact-manager.h>
35
36 #include "empathy-contact-menu.h"
37 #include "empathy-images.h"
38 #include "empathy-log-window.h"
39 #include "empathy-contact-dialogs.h"
40 #include "empathy-ui-utils.h"
41 #include "empathy-share-my-desktop.h"
42 #include "empathy-call-utils.h"
43
44 static GtkWidget *empathy_contact_block_menu_item_new (EmpathyContact *);
45
46 GtkWidget *
47 empathy_contact_menu_new (EmpathyContact             *contact,
48                           EmpathyContactFeatureFlags  features)
49 {
50         GtkWidget    *menu;
51         GtkMenuShell *shell;
52         GtkWidget    *item;
53
54         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
55
56         if (features == EMPATHY_CONTACT_FEATURE_NONE) {
57                 return NULL;
58         }
59
60         menu = gtk_menu_new ();
61         shell = GTK_MENU_SHELL (menu);
62
63         /* Add Contact */
64         item = empathy_contact_add_menu_item_new (contact);
65         if (item) {
66                 gtk_menu_shell_append (shell, item);
67                 gtk_widget_show (item);
68         }
69
70         /* Chat */
71         if (features & EMPATHY_CONTACT_FEATURE_CHAT) {
72                 item = empathy_contact_chat_menu_item_new (contact);
73                 gtk_menu_shell_append (shell, item);
74                 gtk_widget_show (item);
75         }
76
77         if (features & EMPATHY_CONTACT_FEATURE_CALL) {
78                 /* Audio Call */
79                 item = empathy_contact_audio_call_menu_item_new (contact);
80                 gtk_menu_shell_append (shell, item);
81                 gtk_widget_show (item);
82
83                 /* Video Call */
84                 item = empathy_contact_video_call_menu_item_new (contact);
85                 gtk_menu_shell_append (shell, item);
86                 gtk_widget_show (item);
87         }
88
89         /* Invite */
90         item = empathy_contact_invite_menu_item_new (contact);
91         gtk_menu_shell_append (shell, item);
92         gtk_widget_show (item);
93
94         /* File transfer */
95         if (features & EMPATHY_CONTACT_FEATURE_FT) {
96                 item = empathy_contact_file_transfer_menu_item_new (contact);
97                 gtk_menu_shell_append (shell, item);
98                 gtk_widget_show (item);
99         }
100
101         /* Share my desktop */
102         /* FIXME we should add the "Share my desktop" menu item if Vino is
103         a registered handler in MC5 */
104         item = empathy_contact_share_my_desktop_menu_item_new (contact);
105         gtk_menu_shell_append (shell, item);
106         gtk_widget_show (item);
107
108         /* Separator */
109         if (features & (EMPATHY_CONTACT_FEATURE_EDIT |
110                         EMPATHY_CONTACT_FEATURE_INFO)) {
111                 item = gtk_separator_menu_item_new ();
112                 gtk_menu_shell_append (shell, item);
113                 gtk_widget_show (item);
114         }
115
116         /* Edit */
117         if (features & EMPATHY_CONTACT_FEATURE_EDIT) {
118                 item = empathy_contact_edit_menu_item_new (contact);
119                 gtk_menu_shell_append (shell, item);
120                 gtk_widget_show (item);
121         }
122
123         /* Log */
124         if (features & EMPATHY_CONTACT_FEATURE_LOG) {
125                 item = empathy_contact_log_menu_item_new (contact);
126                 gtk_menu_shell_append (shell, item);
127                 gtk_widget_show (item);
128         }
129
130         /* Info */
131         if (features & EMPATHY_CONTACT_FEATURE_INFO) {
132                 item = empathy_contact_info_menu_item_new (contact);
133                 gtk_menu_shell_append (shell, item);
134                 gtk_widget_show (item);
135         }
136
137         /* Separator & Block */
138         if (features & EMPATHY_CONTACT_FEATURE_BLOCK &&
139             (item = empathy_contact_block_menu_item_new (contact)) != NULL) {
140                 GtkWidget *sep;
141
142                 sep = gtk_separator_menu_item_new ();
143                 gtk_menu_shell_append (shell, sep);
144                 gtk_widget_show (sep);
145
146                 gtk_menu_shell_append (shell, item);
147                 gtk_widget_show (item);
148         }
149
150         return menu;
151 }
152
153 static void
154 empathy_contact_add_menu_item_activated (GtkMenuItem *item,
155         EmpathyContact *contact)
156 {
157         GtkWidget *toplevel;
158
159         toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item));
160         if (!gtk_widget_is_toplevel (toplevel) || !GTK_IS_WINDOW (toplevel)) {
161                 toplevel = NULL;
162         }
163
164         empathy_new_contact_dialog_show_with_contact (GTK_WINDOW (toplevel),
165                                                       contact);
166 }
167
168 GtkWidget *
169 empathy_contact_add_menu_item_new (EmpathyContact *contact)
170 {
171         GtkWidget *item;
172         GtkWidget *image;
173         EmpathyContactManager *manager;
174         TpConnection *connection;
175         GList *l, *members;
176         gboolean found = FALSE;
177         EmpathyContactListFlags flags;
178
179         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
180
181         if (!empathy_contact_manager_initialized ()) {
182                 return NULL;
183         }
184
185         manager = empathy_contact_manager_dup_singleton ();
186         connection = empathy_contact_get_connection (contact);
187
188         flags = empathy_contact_manager_get_flags_for_connection (manager,
189                         connection);
190
191         if (!(flags & EMPATHY_CONTACT_LIST_CAN_ADD)) {
192                 return NULL;
193         }
194
195         members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (manager));
196         for (l = members; l; l = l->next) {
197                 if (!found && empathy_contact_equal (l->data, contact)) {
198                         found = TRUE;
199                         /* we keep iterating so that we don't leak contact
200                          * refs */
201                 }
202
203                 g_object_unref (l->data);
204         }
205         g_list_free (members);
206         g_object_unref (manager);
207
208         if (found) {
209                 return NULL;
210         }
211
212         item = gtk_image_menu_item_new_with_mnemonic (_("_Add Contact…"));
213         image = gtk_image_new_from_icon_name (GTK_STOCK_ADD,
214                                               GTK_ICON_SIZE_MENU);
215         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
216
217         g_signal_connect (item, "activate",
218                         G_CALLBACK (empathy_contact_add_menu_item_activated),
219                         contact);
220
221         return item;
222 }
223
224 static void
225 empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item,
226                                          EmpathyContact   *contact)
227 {
228         static guint block_signal = 0;
229         gboolean blocked, abusive;
230         TpContact *tp_contact;
231
232         if (block_signal > 0)
233                 return;
234
235         blocked = gtk_check_menu_item_get_active (item);
236
237         if (blocked) {
238                 /* confirm the user really wishes to block the contact */
239                 GtkWidget *parent;
240                 GdkPixbuf *avatar;
241
242                 /* gtk_menu_get_attach_widget () doesn't behave properly here
243                  * for some reason */
244                 parent = g_object_get_data (
245                         G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (item))),
246                         "window");
247
248                 avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 48, 48);
249
250                 if (!empathy_block_contact_dialog_show (GTK_WINDOW (parent),
251                                         contact, avatar, &abusive))
252                         return;
253         }
254
255         tp_contact = empathy_contact_get_tp_contact (contact);
256
257         if (blocked)
258                 tp_contact_block_async (tp_contact, abusive, NULL, NULL);
259         else
260                 tp_contact_unblock_async (tp_contact, NULL, NULL);
261
262         /* update the toggle with the blocked status */
263         block_signal++;
264         gtk_check_menu_item_set_active (item, blocked);
265         block_signal--;
266 }
267
268 static GtkWidget *
269 empathy_contact_block_menu_item_new (EmpathyContact *contact)
270 {
271         GtkWidget *item;
272         TpConnection *connection;
273         TpContact *tp_contact;
274
275         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
276
277         if (!empathy_contact_manager_initialized ()) {
278                 return NULL;
279         }
280
281         connection = empathy_contact_get_connection (contact);
282
283         if (!tp_proxy_has_interface_by_id (connection,
284                 TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING))
285                 return NULL;
286
287         item = gtk_check_menu_item_new_with_mnemonic (_("_Block Contact"));
288
289         tp_contact = empathy_contact_get_tp_contact (contact);
290
291         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
292                         tp_contact_is_blocked (tp_contact));
293
294         g_signal_connect (item, "toggled",
295                         G_CALLBACK (empathy_contact_block_menu_item_toggled),
296                         contact);
297
298         return item;
299 }
300
301 static void
302 empathy_contact_chat_menu_item_activated (GtkMenuItem *item,
303         EmpathyContact *contact)
304 {
305         empathy_chat_with_contact (contact, empathy_get_current_action_time ());
306 }
307
308 GtkWidget *
309 empathy_contact_chat_menu_item_new (EmpathyContact *contact)
310 {
311         GtkWidget *item;
312         GtkWidget *image;
313
314         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
315
316         item = gtk_image_menu_item_new_with_mnemonic (_("_Chat"));
317         image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_MESSAGE,
318                                               GTK_ICON_SIZE_MENU);
319         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
320         gtk_widget_set_sensitive (item, !empathy_contact_is_user (contact));
321         gtk_widget_show (image);
322
323         g_signal_connect (item, "activate",
324                                   G_CALLBACK (empathy_contact_chat_menu_item_activated),
325                                   contact);
326
327         return item;
328 }
329
330 static void
331 empathy_contact_audio_call_menu_item_activated (GtkMenuItem *item,
332         EmpathyContact *contact)
333 {
334         empathy_call_new_with_streams (empathy_contact_get_id (contact),
335                 empathy_contact_get_account (contact),
336                 TRUE, FALSE,
337                 empathy_get_current_action_time ());
338 }
339
340 GtkWidget *
341 empathy_contact_audio_call_menu_item_new (EmpathyContact *contact)
342 {
343         GtkWidget *item;
344         GtkWidget *image;
345
346         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
347
348         item = gtk_image_menu_item_new_with_mnemonic (C_("menu item", "_Audio Call"));
349         image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
350                                               GTK_ICON_SIZE_MENU);
351         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
352         gtk_widget_set_sensitive (item, empathy_contact_can_voip_audio (contact) &&
353                                         !empathy_contact_is_user (contact));
354         gtk_widget_show (image);
355
356         g_signal_connect (item, "activate",
357                                   G_CALLBACK (empathy_contact_audio_call_menu_item_activated),
358                                   contact);
359
360         return item;
361 }
362
363 static void
364 empathy_contact_video_call_menu_item_activated (GtkMenuItem *item,
365         EmpathyContact *contact)
366 {
367         empathy_call_new_with_streams (empathy_contact_get_id (contact),
368                 empathy_contact_get_account (contact),
369                 TRUE, TRUE,
370                 empathy_get_current_action_time ());
371 }
372
373 GtkWidget *
374 empathy_contact_video_call_menu_item_new (EmpathyContact *contact)
375 {
376         GtkWidget *item;
377         GtkWidget *image;
378
379         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
380
381         item = gtk_image_menu_item_new_with_mnemonic (C_("menu item", "_Video Call"));
382         image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VIDEO_CALL,
383                                               GTK_ICON_SIZE_MENU);
384         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
385         gtk_widget_set_sensitive (item, empathy_contact_can_voip_video (contact) &&
386                                         !empathy_contact_is_user (contact));
387         gtk_widget_show (image);
388
389         g_signal_connect (item, "activate",
390                                   G_CALLBACK (empathy_contact_video_call_menu_item_activated),
391                                   contact);
392
393         return item;
394 }
395
396 static void
397 contact_log_menu_item_activate_cb (EmpathyContact *contact)
398 {
399         empathy_log_window_show (empathy_contact_get_account (contact),
400                                  empathy_contact_get_id (contact),
401                                  FALSE, NULL);
402 }
403
404 GtkWidget *
405 empathy_contact_log_menu_item_new (EmpathyContact *contact)
406 {
407         TplLogManager     *manager;
408         TplEntity         *entity;
409         gboolean           have_log;
410         GtkWidget         *item;
411         GtkWidget         *image;
412
413         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
414
415         manager = tpl_log_manager_dup_singleton ();
416         entity = tpl_entity_new_from_tp_contact (empathy_contact_get_tp_contact (contact),
417                                                  TPL_ENTITY_CONTACT);
418
419         have_log = tpl_log_manager_exists (manager,
420                                            empathy_contact_get_account (contact),
421                                            entity,
422                                            TPL_EVENT_MASK_TEXT);
423
424         g_object_unref (entity);
425         g_object_unref (manager);
426
427         item = gtk_image_menu_item_new_with_mnemonic (_("_Previous Conversations"));
428         image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_LOG,
429                                               GTK_ICON_SIZE_MENU);
430         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
431         gtk_widget_set_sensitive (item, have_log);
432         gtk_widget_show (image);
433
434         g_signal_connect_swapped (item, "activate",
435                                   G_CALLBACK (contact_log_menu_item_activate_cb),
436                                   contact);
437
438         return item;
439 }
440
441 GtkWidget *
442 empathy_contact_file_transfer_menu_item_new (EmpathyContact *contact)
443 {
444         GtkWidget         *item;
445         GtkWidget         *image;
446
447         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
448
449         item = gtk_image_menu_item_new_with_mnemonic (_("Send File"));
450         image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_DOCUMENT_SEND,
451                                               GTK_ICON_SIZE_MENU);
452         gtk_widget_set_sensitive (item, empathy_contact_can_send_files (contact) &&
453                                         !empathy_contact_is_user (contact));
454         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
455         gtk_widget_show (image);
456
457         g_signal_connect_swapped (item, "activate",
458                                   G_CALLBACK (empathy_send_file_with_file_chooser),
459                                   contact);
460
461         return item;
462 }
463
464 GtkWidget *
465 empathy_contact_share_my_desktop_menu_item_new (EmpathyContact *contact)
466 {
467         GtkWidget         *item;
468         GtkWidget         *image;
469
470         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
471
472         item = gtk_image_menu_item_new_with_mnemonic (_("Share My Desktop"));
473         image = gtk_image_new_from_icon_name (GTK_STOCK_NETWORK,
474                                               GTK_ICON_SIZE_MENU);
475         gtk_widget_set_sensitive (item, empathy_contact_can_use_rfb_stream_tube (
476                 contact));
477         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
478         gtk_widget_show (image);
479
480         g_signal_connect_swapped (item, "activate",
481                                   G_CALLBACK (empathy_share_my_desktop_share_with_contact),
482                                   contact);
483
484         return item;
485 }
486
487 static void
488 contact_info_menu_item_activate_cb (EmpathyContact *contact)
489 {
490         empathy_contact_information_dialog_show (contact, NULL);
491 }
492
493 GtkWidget *
494 empathy_contact_info_menu_item_new (EmpathyContact *contact)
495 {
496         GtkWidget *item;
497         GtkWidget *image;
498
499         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
500
501         item = gtk_image_menu_item_new_with_mnemonic (_("Infor_mation"));
502         image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_CONTACT_INFORMATION,
503                                               GTK_ICON_SIZE_MENU);
504         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
505         gtk_widget_show (image);
506
507         g_signal_connect_swapped (item, "activate",
508                                   G_CALLBACK (contact_info_menu_item_activate_cb),
509                                   contact);
510
511         return item;
512 }
513
514 static void
515 contact_edit_menu_item_activate_cb (EmpathyContact *contact)
516 {
517         empathy_contact_edit_dialog_show (contact, NULL);
518 }
519
520 GtkWidget *
521 empathy_contact_edit_menu_item_new (EmpathyContact *contact)
522 {
523         EmpathyContactManager *manager;
524         GtkWidget *item;
525         GtkWidget *image;
526         gboolean enable = FALSE;
527
528         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
529
530         if (empathy_contact_manager_initialized ()) {
531                 TpConnection *connection;
532                 EmpathyContactListFlags flags;
533
534                 manager = empathy_contact_manager_dup_singleton ();
535                 connection = empathy_contact_get_connection (contact);
536                 flags = empathy_contact_manager_get_flags_for_connection (
537                                 manager, connection);
538
539                 enable = (flags & EMPATHY_CONTACT_LIST_CAN_ALIAS ||
540                           flags & EMPATHY_CONTACT_LIST_CAN_GROUP);
541
542                 g_object_unref (manager);
543         }
544
545         item = gtk_image_menu_item_new_with_mnemonic (
546                                                      C_("Edit contact (contextual menu)",
547                                                         "_Edit"));
548         image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT,
549                                               GTK_ICON_SIZE_MENU);
550         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
551         gtk_widget_show (image);
552
553         gtk_widget_set_sensitive (item, enable);
554
555         g_signal_connect_swapped (item, "activate",
556                                   G_CALLBACK (contact_edit_menu_item_activate_cb),
557                                   contact);
558
559         return item;
560 }
561
562 typedef struct  {
563         EmpathyContact *contact;
564         EmpathyChatroom *chatroom;
565 } RoomSubMenuData;
566
567 static RoomSubMenuData *
568 room_sub_menu_data_new (EmpathyContact *contact,
569                         EmpathyChatroom *chatroom)
570 {
571         RoomSubMenuData *data;
572
573         data = g_slice_new (RoomSubMenuData);
574         data->contact = g_object_ref (contact);
575         data->chatroom = g_object_ref (chatroom);
576         return data;
577 }
578
579 static void
580 room_sub_menu_data_free (RoomSubMenuData *data)
581 {
582         g_object_unref (data->contact);
583         g_object_unref (data->chatroom);
584         g_slice_free (RoomSubMenuData, data);
585 }
586
587 static void
588 room_sub_menu_activate_cb (GtkWidget *item,
589                            RoomSubMenuData *data)
590 {
591         EmpathyTpChat *chat;
592
593         chat = empathy_chatroom_get_tp_chat (data->chatroom);
594         if (chat == NULL) {
595                 /* channel was invalidated. Ignoring */
596                 return;
597         }
598
599         /* send invitation */
600         empathy_contact_list_add (EMPATHY_CONTACT_LIST (chat), data->contact,
601                 _("Inviting you to this room"));
602 }
603
604 static GtkWidget *
605 create_room_sub_menu (EmpathyContact *contact,
606                       EmpathyChatroom *chatroom)
607 {
608         GtkWidget *item;
609         RoomSubMenuData *data;
610
611         item = gtk_menu_item_new_with_label (empathy_chatroom_get_name (chatroom));
612         data = room_sub_menu_data_new (contact, chatroom);
613         g_signal_connect_data (item, "activate",
614                                G_CALLBACK (room_sub_menu_activate_cb), data,
615                                (GClosureNotify) room_sub_menu_data_free, 0);
616
617         return item;
618 }
619
620 GtkWidget *
621 empathy_contact_invite_menu_item_new (EmpathyContact *contact)
622 {
623         GtkWidget *item;
624         GtkWidget *image;
625         GtkWidget *room_item;
626         EmpathyChatroomManager *mgr;
627         GList *rooms, *l;
628         GtkWidget *submenu = NULL;
629
630         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
631
632         item = gtk_image_menu_item_new_with_mnemonic (_("_Invite to Chat Room"));
633         image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_GROUP_MESSAGE,
634                                               GTK_ICON_SIZE_MENU);
635         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
636
637         if (empathy_contact_is_user (contact)) {
638                 gtk_widget_set_sensitive (item, FALSE);
639                 gtk_widget_show (image);
640                 return item;
641         }
642
643         mgr = empathy_chatroom_manager_dup_singleton (NULL);
644         rooms = empathy_chatroom_manager_get_chatrooms (mgr,
645                 empathy_contact_get_account (contact));
646
647         for (l = rooms; l != NULL; l = g_list_next (l)) {
648                 EmpathyChatroom *chatroom = l->data;
649
650                 if (empathy_chatroom_get_tp_chat (chatroom) != NULL) {
651                         if (G_UNLIKELY (submenu == NULL))
652                                 submenu = gtk_menu_new ();
653
654                         room_item = create_room_sub_menu (contact, chatroom);
655                         gtk_menu_shell_append ((GtkMenuShell *) submenu, room_item);
656                         gtk_widget_show (room_item);
657                 }
658         }
659
660         if (submenu) {
661                 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
662         } else {
663                 gtk_widget_set_sensitive (item, FALSE);
664         }
665
666         gtk_widget_show (image);
667
668         g_object_unref (mgr);
669         g_list_free (rooms);
670
671         return item;
672 }
673