2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002 Match Grun
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program 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
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Contains address clipboard objects and related functions. The address
22 * clipboard is implemented as a linked list of AddrSelectItem objects.
23 * The address clipboard offers two groups of functions:
25 * a) Cut, copy and paste of address item objects (ItemFolder, ItemGroup,
26 * ItemPerson) into a folder. With this method, we can paste ItemPerson
27 * objects but not unattached ItemEMail objects into a folder. ItemEMail
28 * objects are owned by an ItemPerson object. Any ItemEMail objects that
29 * appear in the clipboard are ignored. If an ItemPerson object is found,
30 * the ItemPerson *and* ItemEMail objects that it owns are pasted.
32 * b) Copy and paste of ItemEMail address objects only into (below)
33 * ItemPerson objects. All ItemEMail objects which are owned by
34 * ItemPerson and referenced by ItemGroup objects are pasted. Any
35 * ItemFolder objects in the clipboard, and any objects owned by
36 * ItemFolder objects are ignored.
38 * Objects are inserted to the clipboard by copying (cloning)
39 * AddrSelectItem objects from the address books selection list to the
40 * clipboard's internal selection list. The clipboard makes use of the
41 * object id's and address cache id's to access objects contained in
42 * the address cache. If the referenced object is not found, it is
43 * ignored. This eliminates the need to delete pointers in multiple
44 * linked lists when an address object is deleted.
51 #include "addrcache.h"
53 #include "addrselect.h"
54 #include "addrindex.h"
60 AddressClipboard *addrclip_create( void ) {
61 AddressClipboard *clipBoard;
63 clipBoard = g_new0( AddressClipboard, 1 );
64 clipBoard->cutFlag = FALSE;
65 clipBoard->objectList = NULL;
72 void addrclip_clear( AddressClipboard *clipBoard ) {
76 g_return_if_fail( clipBoard != NULL );
77 node = clipBoard->objectList;
80 addrselect_item_free( item );
82 node = g_list_next( node );
84 g_list_free( clipBoard->objectList );
85 clipBoard->objectList = NULL;
89 * Free up a clipboard.
91 void addrclip_free( AddressClipboard *clipBoard ) {
92 g_return_if_fail( clipBoard != NULL );
94 addrclip_clear( clipBoard );
95 clipBoard->cutFlag = FALSE;
99 * Setup reference to address index.
101 void addrclip_set_index(
102 AddressClipboard *clipBoard, AddressIndex *addrIndex )
104 g_return_if_fail( clipBoard != NULL );
105 g_return_if_fail( addrIndex != NULL );
106 clipBoard->addressIndex = addrIndex;
110 * Test whether clipboard is empty.
111 * Enter: clipBoard Clipboard.
112 * Return: TRUE if clipboard is empty.
114 gboolean addrclip_is_empty( AddressClipboard *clipBoard ) {
115 gboolean retVal = TRUE;
118 if( clipBoard->objectList ) retVal = FALSE;
124 * Add a list of address selection objects to clipbard.
125 * Enter: clipBoard Clipboard.
126 * addrList List of address selection objects.
128 void addrclip_add( AddressClipboard *clipBoard, AddrSelectList *asl ) {
131 g_return_if_fail( clipBoard != NULL );
132 g_return_if_fail( asl != NULL );
133 node = asl->listSelect;
135 AddrSelectItem *item, *itemCopy;
138 itemCopy = addrselect_item_copy( item );
139 clipBoard->objectList =
140 g_list_append( clipBoard->objectList, itemCopy );
141 node = g_list_next( node );
146 * Add a single address selection objects to clipbard.
147 * Enter: clipBoard Clipboard.
148 * item Address selection object.
150 void addrclip_add_item(
151 AddressClipboard *clipBoard, AddrSelectItem *item )
153 g_return_if_fail( clipBoard != NULL );
155 AddrSelectItem *itemCopy;
157 itemCopy = addrselect_item_copy( item );
158 clipBoard->objectList =
159 g_list_append( clipBoard->objectList, itemCopy );
164 * Show clipboard contents.
165 * Enter: clipBoard Clipboard.
166 * stream Output stream.
168 void addrclip_list_show( AddressClipboard *clipBoard, FILE *stream ) {
173 g_return_if_fail( clipBoard != NULL );
174 node = clipBoard->objectList;
175 while( node != NULL ) {
176 AddrSelectItem *item;
179 addrselect_item_print( item, stream );
181 cache = addrindex_get_cache( clipBoard->addressIndex, item->cacheID );
182 aio = addrcache_get_object( cache, item->uid );
184 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
185 addritem_print_item_person( ( ItemPerson * ) aio, stream );
187 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
188 addritem_print_item_email( ( ItemEMail * ) aio, stream );
190 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
191 addritem_print_item_group( ( ItemGroup * ) aio, stream );
193 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
194 addritem_print_item_folder( ( ItemFolder * ) aio, stream );
197 node = g_list_next( node );
201 /* Pasted address pointers */
202 typedef struct _AddrClip_EMail_ AddrClip_EMail;
203 struct _AddrClip_EMail_ {
209 * Free up specified list of addresses.
211 static void addrclip_free_copy_list( GList *copyList ) {
216 AddrClip_EMail *em = node->data;
221 node = g_list_next( node );
226 * Paste person into cache.
227 * Enter: cache Address cache to paste into.
228 * folder Folder to store
229 * person Person to paste.
230 * copyLIst List of email addresses pasted.
231 * Return: Update list of email addresses pasted.
233 static GList *addrclip_cache_add_person(
234 AddressCache *cache, ItemFolder *folder, ItemPerson *person,
237 ItemPerson *newPerson;
240 UserAttribute *attrib;
241 UserAttribute *newAttrib;
246 newPerson = addritem_copy_item_person( person );
247 addrcache_id_person( cache, newPerson );
248 addrcache_folder_add_person( cache, folder, newPerson );
250 /* Copy email addresses */
251 node = person->listEMail;
254 newEMail = addritem_copy_item_email( email );
255 addrcache_id_email( cache, newEMail );
256 addrcache_person_add_email( cache, newPerson, newEMail );
257 node = g_list_next( node );
259 /* Take a copy of the original */
260 em = g_new0( AddrClip_EMail, 1 );
261 em->original = email;
263 copyList = g_list_append( copyList, em );
266 /* Copy user attributes */
267 node = person->listAttrib;
270 newAttrib = addritem_copy_attribute( attrib );
271 addrcache_id_attribute( cache, newAttrib );
272 addritem_person_add_attribute( newPerson, newAttrib );
273 node = g_list_next( node );
280 * Search for new email record in copied email list.
281 * Enter: copyList List of copied email address mappings.
282 * emailOrig Original email item.
283 * Return: New email item corresponding to original item if pasted. Or NULL if
286 static ItemEMail *addrclip_find_copied_email(
287 GList *copyList, ItemEMail *emailOrig )
289 ItemEMail *emailCopy;
297 if( em->original == emailOrig ) {
298 emailCopy = em->copy;
301 node = g_list_next( node );
307 * Paste group into cache.
308 * Enter: cache Address cache to paste into.
309 * folder Folder to store
310 * group Group to paste.
311 * copyList List of email addresses pasted.
312 * Return: Group added.
314 static ItemGroup *addrclip_cache_add_group(
315 AddressCache *cache, ItemFolder *folder, ItemGroup *group,
319 ItemEMail *emailOrig, *emailCopy;
323 newGroup = addritem_copy_item_group( group );
324 addrcache_id_group( cache, newGroup );
325 addrcache_folder_add_group( cache, folder, newGroup );
327 /* Add references of copied addresses to group */
328 node = group->listEMail;
330 emailOrig = ( ItemEMail * ) node->data;
331 emailCopy = addrclip_find_copied_email( copyList, emailOrig );
333 addrcache_group_add_email( cache, newGroup, emailCopy );
335 node = g_list_next( node );
341 * Copy specified folder into cache. Note this functions uses pointers to
342 * folders to copy from. There should not be any deleted items referenced
343 * by these pointers!!!
344 * Enter: cache Address cache to copy into.
345 * targetFolder Target folder.
346 * folder Folder to copy.
347 * Return: Folder added.
349 static ItemFolder *addrclip_cache_copy_folder(
350 AddressCache *cache, ItemFolder *targetFolder, ItemFolder *folder )
352 ItemFolder *newFolder;
358 newFolder = addritem_copy_item_folder( folder );
359 addrcache_id_folder( cache, newFolder );
360 addrcache_folder_add_folder( cache, targetFolder, newFolder );
362 /* Copy people to new folder */
364 node = folder->listPerson;
366 ItemPerson *item = node->data;
367 node = g_list_next( node );
368 copyList = addrclip_cache_add_person(
369 cache, newFolder, item, copyList );
372 /* Copy groups to new folder */
373 node = folder->listGroup;
375 ItemGroup *item = node->data;
376 node = g_list_next( node );
377 newGroup = addrclip_cache_add_group(
378 cache, newFolder, item, copyList );
380 g_list_free( copyList );
382 /* Copy folders to new folder (recursive) */
383 node = folder->listFolder;
385 ItemFolder *item = node->data;
386 node = g_list_next( node );
387 addrclip_cache_copy_folder( cache, newFolder, item );
394 * Paste item list into address book.
395 * Enter: cache Target address cache.
396 * folder Target folder where data is pasted.
397 * itemList List of items to paste.
398 * clipBoard Clipboard.
399 * Return: List of group or folder items added.
401 static GList *addrclip_cache_add_folder(
402 AddressCache *cache, ItemFolder *folder, GList *itemList,
403 AddressClipboard *clipBoard )
407 AddrSelectItem *item;
409 AddressCache *cacheFrom;
419 node = g_list_next( node );
421 cacheFrom = addrindex_get_cache(
422 clipBoard->addressIndex, item->cacheID );
423 if( cacheFrom == NULL ) continue;
425 aio = addrcache_get_object( cacheFrom, item->uid );
427 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
430 person = ( ItemPerson * ) aio;
431 copyList = addrclip_cache_add_person(
432 cache, folder, person, copyList );
435 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
438 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
439 haveGroups = TRUE; /* Process later */
441 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
442 ItemFolder *itemFolder, *newFolder;
444 itemFolder = ( ItemFolder * ) aio;
445 newFolder = addrclip_cache_copy_folder(
446 cache, folder, itemFolder );
448 g_list_append( folderGroup, newFolder );
453 if( item->objectType == ITEMTYPE_DATASOURCE ) {
455 * Must be an address book - allow copy only if
456 * copying from a different cache.
458 if( cache != cacheFrom ) {
459 ItemFolder *itemFolder, *newFolder;
461 itemFolder = cacheFrom->rootFolder;
462 newFolder = addrclip_cache_copy_folder(
463 cache, folder, itemFolder );
464 addritem_folder_set_name( newFolder,
465 addrcache_get_name( cacheFrom ) );
467 g_list_append( folderGroup, newFolder );
473 /* Finally add any groups */
478 node = g_list_next( node );
479 cacheFrom = addrindex_get_cache(
480 clipBoard->addressIndex, item->cacheID );
481 if( cacheFrom == NULL ) continue;
482 aio = addrcache_get_object( cacheFrom, item->uid );
484 if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
485 ItemGroup *group, *newGroup;
487 group = ( ItemGroup * ) aio;
488 newGroup = addrclip_cache_add_group(
489 cache, folder, group, copyList );
491 g_list_append( folderGroup, newGroup );
498 addrclip_free_copy_list( copyList );
499 g_list_free( copyList );
506 * Move items in list into new folder
507 * Enter: cache Target address cache.
508 * targetFolder Target folder where data is pasted.
509 * itemList List of items to paste.
510 * clipBoard Clipboard.
511 * Return: List of group or folder items added.
513 static GList *addrclip_cache_move_items(
514 AddressCache *cache, ItemFolder *targetFolder, GList *itemList,
515 AddressClipboard *clipBoard )
519 AddrSelectItem *item;
521 AddressCache *cacheFrom;
527 node = g_list_next( node );
528 cacheFrom = addrindex_get_cache(
529 clipBoard->addressIndex, item->cacheID );
530 if( cacheFrom == NULL ) continue;
531 aio = addrcache_get_object( cacheFrom, item->uid );
533 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
536 person = ( ItemPerson * ) aio;
537 addrcache_folder_move_person(
538 cache, person, targetFolder );
540 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
543 group = ( ItemGroup * ) aio;
544 addrcache_folder_move_group(
545 cache, group, targetFolder );
546 folderGroup = g_list_append( folderGroup, group );
548 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
551 folder = ( ItemFolder * ) aio;
552 addrcache_folder_move_folder(
553 cache, folder, targetFolder );
555 g_list_append( folderGroup, folder );
563 * Get address cache of first item in list. This assumes that all items in
564 * the clipboard are located in the same cache.
565 * Enter: clipBoard Clipboard.
566 * Return: List of group or folder items added.
568 static AddressCache *addrclip_list_get_cache( AddressClipboard *clipBoard ) {
571 AddrSelectItem *item;
574 itemList = clipBoard->objectList;
576 item = itemList->data;
577 cache = addrindex_get_cache(
578 clipBoard->addressIndex, item->cacheID );
584 * Paste (copy) clipboard into address book.
585 * Enter: clipBoard Clipboard.
586 * book Target address book.
587 * folder Target folder where data is pasted, or null for root folder.
588 * Return: List of group or folder items added.
590 GList *addrclip_paste_copy(
591 AddressClipboard *clipBoard, AddressBookFile *book,
598 g_return_val_if_fail( clipBoard != NULL, NULL );
600 cache = book->addressCache;
601 if( folder == NULL ) folder = cache->rootFolder;
604 itemList = clipBoard->objectList;
605 folderGroup = addrclip_cache_add_folder(
606 cache, folder, itemList, clipBoard );
612 * Remove items that were cut from clipboard.
613 * Enter: clipBoard Clipboard.
615 void addrclip_delete_item( AddressClipboard *clipBoard ) {
616 AddrSelectItem *item;
618 AddressCache *cacheFrom;
621 /* If cutting within current cache, no deletion is necessary */
622 if( clipBoard->moveFlag ) return;
625 node = clipBoard->objectList;
628 node = g_list_next( node );
629 cacheFrom = addrindex_get_cache(
630 clipBoard->addressIndex, item->cacheID );
631 if( cacheFrom == NULL ) continue;
632 aio = addrcache_get_object( cacheFrom, item->uid );
634 if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
637 group = ( ItemGroup * ) aio;
638 group = addrcache_remove_group( cacheFrom, group );
640 addritem_free_item_group( group );
646 /* Remove persons and folders */
647 node = clipBoard->objectList;
650 node = g_list_next( node );
652 cacheFrom = addrindex_get_cache(
653 clipBoard->addressIndex, item->cacheID );
654 if( cacheFrom == NULL ) continue;
656 aio = addrcache_get_object( cacheFrom, item->uid );
658 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
661 person = ( ItemPerson * ) aio;
662 person = addrcache_remove_person( cacheFrom, person );
664 addritem_free_item_person( person );
667 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
668 ItemFolder *itemFolder;
670 itemFolder = ( ItemFolder * ) aio;
671 itemFolder = addrcache_remove_folder_delete(
672 cacheFrom, itemFolder );
673 addritem_free_item_folder( itemFolder );
680 * Paste (move) clipboard into address book.
681 * Enter: clipBoard Clipboard.
682 * book Target address book.
683 * folder Target folder where data is pasted, or null for root folder.
684 * Return: List of group or folder items added.
686 GList *addrclip_paste_cut(
687 AddressClipboard *clipBoard, AddressBookFile *book,
690 AddressCache *cache, *cacheFrom;
694 g_return_val_if_fail( clipBoard != NULL, NULL );
696 cache = book->addressCache;
697 if( folder == NULL ) folder = cache->rootFolder;
700 clipBoard->moveFlag = FALSE;
701 cacheFrom = addrclip_list_get_cache( clipBoard );
702 if( cacheFrom && cacheFrom == cache ) {
703 /* Move items between folders in same book */
704 itemList = clipBoard->objectList;
705 folderGroup = addrclip_cache_move_items(
706 cache, folder, itemList, clipBoard );
707 clipBoard->moveFlag = TRUE;
710 /* Move items across address books */
711 itemList = clipBoard->objectList;
712 folderGroup = addrclip_cache_add_folder(
713 cache, folder, itemList, clipBoard );
720 * ============================================================================
721 * Paste address only.
722 * ============================================================================
726 * Copy email addresses from specified list.
727 * Enter: cache Address cache to paste into.
728 * target Person to receive email addresses.
729 * listEMail List of email addresses.
730 * Return: Number of addresses added.
732 static gint addrclip_person_add_email(
733 AddressCache *cache, ItemPerson *target, GList *listEMail )
738 /* Copy email addresses */
742 ItemEMail *email, *newEMail;
745 newEMail = addritem_copy_item_email( email );
746 addrcache_id_email( cache, newEMail );
747 addrcache_person_add_email( cache, target, newEMail );
748 node = g_list_next( node );
755 * Paste (copy) E-Mail addresses from clipboard into specified person.
756 * Enter: aio Address item to copy from.
757 * cache Target address cache.
758 * person Target person where data is pasted.
759 * Return: Number of EMail records added.
761 static gint addrclip_copy_email_to_person(
762 AddrItemObject *aio, AddressCache *cache, ItemPerson *person )
769 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
770 ItemPerson *fromPerson;
772 fromPerson = ( ItemPerson * ) aio;
773 listEMail = fromPerson->listEMail;
774 cnt += addrclip_person_add_email(
775 cache, person, listEMail );
777 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
778 ItemEMail *email, *newEMail;
780 email = ( ItemEMail * ) aio;
781 newEMail = addritem_copy_item_email( email );
782 addrcache_id_email( cache, newEMail );
783 addrcache_person_add_email( cache, person, newEMail );
786 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
789 group = ( ItemGroup * ) aio;
790 listEMail = group->listEMail;
791 cnt += addrclip_person_add_email(
792 cache, person, listEMail );
794 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
796 AddrItemObject *item;
799 folder = ( ItemFolder * ) aio;
800 node = folder->listPerson;
803 node = g_list_next( node );
804 cnt += addrclip_copy_email_to_person( item, cache, person );
807 node = folder->listGroup;
810 node = g_list_next( node );
811 cnt += addrclip_copy_email_to_person( item, cache, person );
814 node = folder->listFolder;
817 node = g_list_next( node );
818 cnt += addrclip_copy_email_to_person( item, cache, person );
825 * Paste (copy) E-Mail addresses from clipboard into specified person.
826 * Enter: clipBoard Clipboard.
827 * cache Target address cache.
828 * person Target person where data is pasted.
829 * Return: Number of EMail records added.
831 static gint addrclip_copyto_person(
832 AddressClipboard *clipBoard, AddressCache *cache, ItemPerson *person )
838 node = clipBoard->objectList;
840 AddressCache *cacheFrom;
841 AddrSelectItem *item;
845 node = g_list_next( node );
846 cacheFrom = addrindex_get_cache(
847 clipBoard->addressIndex, item->cacheID );
848 if( cacheFrom == NULL ) continue;
849 aio = addrcache_get_object( cacheFrom, item->uid );
851 cnt += addrclip_copy_email_to_person( aio, cache, person );
858 * Paste (copy) E-Mail addresses from clipboard into specified person.
859 * Enter: clipBoard Clipboard.
860 * book Target address book.
861 * person Target person where data is pasted.
862 * Return: Number of EMail records added.
864 gint addrclip_paste_person_copy(
865 AddressClipboard *clipBoard, AddressBookFile *book,
872 g_return_val_if_fail( clipBoard != NULL, cnt );
874 cache = book->addressCache;
876 cnt = addrclip_copyto_person( clipBoard, cache, person );
882 * Move email addresses for specified person to target person.
883 * Enter: cache Address cache to paste into.
884 * fromPerson Person supplying email addresses.
885 * target Person to receive email addresses.
886 * Return: Number of addresses moved.
888 static gint addrclip_person_move_email(
889 AddressCache *cache, ItemPerson *fromPerson, ItemPerson *target )
895 while( (node = fromPerson->listEMail) != NULL ) {
899 addrcache_person_move_email( cache, email, target );
906 * Paste (cut) E-Mail addresses from clipboard into specified person.
907 * Enter: clipBoard Clipboard.
908 * cache Target address cache.
909 * person Target person where data is pasted.
910 * Return: Number of EMail records added.
912 static gint addrclip_paste_person_move(
913 AddressClipboard *clipBoard, AddressCache *cache, ItemPerson *person )
916 AddressCache *cacheFrom;
917 AddrSelectItem *item;
923 node = clipBoard->objectList;
926 node = g_list_next( node );
927 cacheFrom = addrindex_get_cache(
928 clipBoard->addressIndex, item->cacheID );
929 if( cacheFrom == NULL ) continue;
930 aio = addrcache_get_object( cacheFrom, item->uid );
932 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
933 ItemPerson *fromPerson;
935 fromPerson = ( ItemPerson * ) aio;
936 cnt += addrclip_person_move_email(
937 cache, fromPerson, person );
939 if( addritem_person_empty( fromPerson ) ) {
941 addrcache_remove_person(
942 cacheFrom, fromPerson );
943 if( fromPerson != NULL ) {
944 addritem_free_item_person( fromPerson );
949 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
952 email = ( ItemEMail * ) aio;
953 addrcache_person_move_email(
954 cache, email, person );
957 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
960 group = ( ItemGroup * ) aio;
961 listEMail = group->listEMail;
962 cnt += addrclip_person_add_email(
963 cache, person, listEMail );
971 * Paste (cut) E-Mail addresses from clipboard into specified person.
972 * Enter: clipBoard Clipboard.
973 * book Target address book.
974 * person Target person where data is pasted.
975 * Return: Number of EMail records added.
977 gint addrclip_paste_person_cut(
978 AddressClipboard *clipBoard, AddressBookFile *book,
982 AddressCache *cache, *cacheFrom;
985 g_return_val_if_fail( clipBoard != NULL, cnt );
987 cache = book->addressCache;
989 clipBoard->moveFlag = FALSE;
990 cacheFrom = addrclip_list_get_cache( clipBoard );
991 if( cacheFrom && cacheFrom == cache ) {
992 cnt = addrclip_paste_person_move(
993 clipBoard, cache, person );
994 clipBoard->moveFlag = TRUE;
997 /* Move items across address books */
998 cnt = addrclip_copyto_person(
999 clipBoard, cache, person );
1006 * Remove address items that were cut from clipboard. Note that that only
1007 * E-Mail items are actually deleted. Any Person items will not be deleted
1008 * (not even E-Mail items that owned by a person). Any Group or Folder
1009 * items will *NOT* be deleted.
1010 * Enter: clipBoard Clipboard.
1012 void addrclip_delete_address( AddressClipboard *clipBoard ) {
1013 AddrSelectItem *item;
1014 AddrItemObject *aio;
1015 AddressCache *cacheFrom;
1018 /* If cutting within current cache, no deletion is necessary */
1019 if( clipBoard->moveFlag ) return;
1022 node = clipBoard->objectList;
1025 node = g_list_next( node );
1026 cacheFrom = addrindex_get_cache(
1027 clipBoard->addressIndex, item->cacheID );
1028 if( cacheFrom == NULL ) continue;
1029 aio = addrcache_get_object( cacheFrom, item->uid );
1031 if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
1035 email = ( ItemEMail * ) aio;
1036 person = ( ItemPerson * ) ADDRITEM_PARENT(email);
1037 email = addrcache_person_remove_email(
1038 cacheFrom, person, email );
1040 addritem_free_item_email( email );