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.
52 #include "addrcache.h"
54 #include "addrselect.h"
55 #include "addrindex.h"
61 AddressClipboard *addrclip_create( void ) {
62 AddressClipboard *clipBoard;
64 clipBoard = g_new0( AddressClipboard, 1 );
65 clipBoard->cutFlag = FALSE;
66 clipBoard->objectList = NULL;
73 void addrclip_clear( AddressClipboard *clipBoard ) {
77 g_return_if_fail( clipBoard != NULL );
78 node = clipBoard->objectList;
81 addrselect_item_free( item );
83 node = g_list_next( node );
85 g_list_free( clipBoard->objectList );
86 clipBoard->objectList = NULL;
90 * Free up a clipboard.
92 void addrclip_free( AddressClipboard *clipBoard ) {
93 g_return_if_fail( clipBoard != NULL );
95 addrclip_clear( clipBoard );
96 clipBoard->cutFlag = FALSE;
100 * Setup reference to address index.
102 void addrclip_set_index(
103 AddressClipboard *clipBoard, AddressIndex *addrIndex )
105 g_return_if_fail( clipBoard != NULL );
106 g_return_if_fail( addrIndex != NULL );
107 clipBoard->addressIndex = addrIndex;
111 * Test whether clipboard is empty.
112 * Enter: clipBoard Clipboard.
113 * Return: TRUE if clipboard is empty.
115 gboolean addrclip_is_empty( AddressClipboard *clipBoard ) {
116 gboolean retVal = TRUE;
119 if( clipBoard->objectList ) retVal = FALSE;
125 * Add a list of address selection objects to clipbard.
126 * Enter: clipBoard Clipboard.
127 * addrList List of address selection objects.
129 void addrclip_add( AddressClipboard *clipBoard, AddrSelectList *asl ) {
132 g_return_if_fail( clipBoard != NULL );
133 g_return_if_fail( asl != NULL );
134 node = asl->listSelect;
136 AddrSelectItem *item, *itemCopy;
139 itemCopy = addrselect_item_copy( item );
140 clipBoard->objectList =
141 g_list_append( clipBoard->objectList, itemCopy );
142 node = g_list_next( node );
147 * Add a single address selection objects to clipbard.
148 * Enter: clipBoard Clipboard.
149 * item Address selection object.
151 void addrclip_add_item(
152 AddressClipboard *clipBoard, AddrSelectItem *item )
154 g_return_if_fail( clipBoard != NULL );
156 AddrSelectItem *itemCopy;
158 itemCopy = addrselect_item_copy( item );
159 clipBoard->objectList =
160 g_list_append( clipBoard->objectList, itemCopy );
165 * Show clipboard contents.
166 * Enter: clipBoard Clipboard.
167 * stream Output stream.
169 void addrclip_list_show( AddressClipboard *clipBoard, FILE *stream ) {
174 g_return_if_fail( clipBoard != NULL );
175 node = clipBoard->objectList;
176 while( node != NULL ) {
177 AddrSelectItem *item;
180 addrselect_item_print( item, stream );
182 cache = addrindex_get_cache( clipBoard->addressIndex, item->cacheID );
183 aio = addrcache_get_object( cache, item->uid );
185 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
186 addritem_print_item_person( ( ItemPerson * ) aio, stream );
188 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
189 addritem_print_item_email( ( ItemEMail * ) aio, stream );
191 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
192 addritem_print_item_group( ( ItemGroup * ) aio, stream );
194 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
195 addritem_print_item_folder( ( ItemFolder * ) aio, stream );
198 node = g_list_next( node );
202 /* Pasted address pointers */
203 typedef struct _AddrClip_EMail_ AddrClip_EMail;
204 struct _AddrClip_EMail_ {
210 * Free up specified list of addresses.
212 static void addrclip_free_copy_list( GList *copyList ) {
217 AddrClip_EMail *em = node->data;
222 node = g_list_next( node );
227 * Paste person into cache.
228 * Enter: cache Address cache to paste into.
229 * folder Folder to store
230 * person Person to paste.
231 * copyLIst List of email addresses pasted.
232 * Return: Update list of email addresses pasted.
234 static GList *addrclip_cache_add_person(
235 AddressCache *cache, ItemFolder *folder, ItemPerson *person,
238 ItemPerson *newPerson;
241 UserAttribute *attrib;
242 UserAttribute *newAttrib;
247 newPerson = addritem_copy_item_person( person );
248 addrcache_id_person( cache, newPerson );
249 addrcache_folder_add_person( cache, folder, newPerson );
251 /* Copy email addresses */
252 node = person->listEMail;
255 newEMail = addritem_copy_item_email( email );
256 addrcache_id_email( cache, newEMail );
257 addrcache_person_add_email( cache, newPerson, newEMail );
258 node = g_list_next( node );
260 /* Take a copy of the original */
261 em = g_new0( AddrClip_EMail, 1 );
262 em->original = email;
264 copyList = g_list_append( copyList, em );
267 /* Copy user attributes */
268 node = person->listAttrib;
271 newAttrib = addritem_copy_attribute( attrib );
272 addrcache_id_attribute( cache, newAttrib );
273 addritem_person_add_attribute( newPerson, newAttrib );
274 node = g_list_next( node );
281 * Search for new email record in copied email list.
282 * Enter: copyList List of copied email address mappings.
283 * emailOrig Original email item.
284 * Return: New email item corresponding to original item if pasted. Or NULL if
287 static ItemEMail *addrclip_find_copied_email(
288 GList *copyList, ItemEMail *emailOrig )
290 ItemEMail *emailCopy;
298 if( em->original == emailOrig ) {
299 emailCopy = em->copy;
302 node = g_list_next( node );
308 * Paste group into cache.
309 * Enter: cache Address cache to paste into.
310 * folder Folder to store
311 * group Group to paste.
312 * copyList List of email addresses pasted.
313 * Return: Group added.
315 static ItemGroup *addrclip_cache_add_group(
316 AddressCache *cache, ItemFolder *folder, ItemGroup *group,
320 ItemEMail *emailOrig, *emailCopy;
324 newGroup = addritem_copy_item_group( group );
325 addrcache_id_group( cache, newGroup );
326 addrcache_folder_add_group( cache, folder, newGroup );
328 /* Add references of copied addresses to group */
329 node = group->listEMail;
331 emailOrig = ( ItemEMail * ) node->data;
332 emailCopy = addrclip_find_copied_email( copyList, emailOrig );
334 addrcache_group_add_email( cache, newGroup, emailCopy );
336 node = g_list_next( node );
342 * Copy specified folder into cache. Note this functions uses pointers to
343 * folders to copy from. There should not be any deleted items referenced
344 * by these pointers!!!
345 * Enter: cache Address cache to copy into.
346 * targetFolder Target folder.
347 * folder Folder to copy.
348 * Return: Folder added.
350 static ItemFolder *addrclip_cache_copy_folder(
351 AddressCache *cache, ItemFolder *targetFolder, ItemFolder *folder )
353 ItemFolder *newFolder;
359 newFolder = addritem_copy_item_folder( folder );
360 addrcache_id_folder( cache, newFolder );
361 addrcache_folder_add_folder( cache, targetFolder, newFolder );
363 /* Copy people to new folder */
365 node = folder->listPerson;
367 ItemPerson *item = node->data;
368 node = g_list_next( node );
369 copyList = addrclip_cache_add_person(
370 cache, newFolder, item, copyList );
373 /* Copy groups to new folder */
374 node = folder->listGroup;
376 ItemGroup *item = node->data;
377 node = g_list_next( node );
378 newGroup = addrclip_cache_add_group(
379 cache, newFolder, item, copyList );
381 g_list_free( copyList );
383 /* Copy folders to new folder (recursive) */
384 node = folder->listFolder;
386 ItemFolder *item = node->data;
387 node = g_list_next( node );
388 addrclip_cache_copy_folder( cache, newFolder, item );
395 * Paste item list into address book.
396 * Enter: cache Target address cache.
397 * folder Target folder where data is pasted.
398 * itemList List of items to paste.
399 * clipBoard Clipboard.
400 * Return: List of group or folder items added.
402 static GList *addrclip_cache_add_folder(
403 AddressCache *cache, ItemFolder *folder, GList *itemList,
404 AddressClipboard *clipBoard )
408 AddrSelectItem *item;
410 AddressCache *cacheFrom;
420 node = g_list_next( node );
422 cacheFrom = addrindex_get_cache(
423 clipBoard->addressIndex, item->cacheID );
424 if( cacheFrom == NULL ) continue;
426 aio = addrcache_get_object( cacheFrom, item->uid );
428 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
431 person = ( ItemPerson * ) aio;
432 copyList = addrclip_cache_add_person(
433 cache, folder, person, copyList );
436 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
439 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
440 haveGroups = TRUE; /* Process later */
442 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
443 ItemFolder *itemFolder, *newFolder;
445 itemFolder = ( ItemFolder * ) aio;
446 newFolder = addrclip_cache_copy_folder(
447 cache, folder, itemFolder );
449 g_list_append( folderGroup, newFolder );
454 if( item->objectType == ITEMTYPE_DATASOURCE ) {
456 * Must be an address book - allow copy only if
457 * copying from a different cache.
459 if( cache != cacheFrom ) {
460 ItemFolder *itemFolder, *newFolder;
462 itemFolder = cacheFrom->rootFolder;
463 newFolder = addrclip_cache_copy_folder(
464 cache, folder, itemFolder );
465 addritem_folder_set_name( newFolder,
466 addrcache_get_name( cacheFrom ) );
468 g_list_append( folderGroup, newFolder );
474 /* Finally add any groups */
479 node = g_list_next( node );
480 cacheFrom = addrindex_get_cache(
481 clipBoard->addressIndex, item->cacheID );
482 if( cacheFrom == NULL ) continue;
483 aio = addrcache_get_object( cacheFrom, item->uid );
485 if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
486 ItemGroup *group, *newGroup;
488 group = ( ItemGroup * ) aio;
489 newGroup = addrclip_cache_add_group(
490 cache, folder, group, copyList );
492 g_list_append( folderGroup, newGroup );
499 addrclip_free_copy_list( copyList );
500 g_list_free( copyList );
507 * Move items in list into new folder
508 * Enter: cache Target address cache.
509 * targetFolder Target folder where data is pasted.
510 * itemList List of items to paste.
511 * clipBoard Clipboard.
512 * Return: List of group or folder items added.
514 static GList *addrclip_cache_move_items(
515 AddressCache *cache, ItemFolder *targetFolder, GList *itemList,
516 AddressClipboard *clipBoard )
520 AddrSelectItem *item;
522 AddressCache *cacheFrom;
528 node = g_list_next( node );
529 cacheFrom = addrindex_get_cache(
530 clipBoard->addressIndex, item->cacheID );
531 if( cacheFrom == NULL ) continue;
532 aio = addrcache_get_object( cacheFrom, item->uid );
534 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
537 person = ( ItemPerson * ) aio;
538 addrcache_folder_move_person(
539 cache, person, targetFolder );
541 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
544 group = ( ItemGroup * ) aio;
545 addrcache_folder_move_group(
546 cache, group, targetFolder );
547 folderGroup = g_list_append( folderGroup, group );
549 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
552 folder = ( ItemFolder * ) aio;
553 addrcache_folder_move_folder(
554 cache, folder, targetFolder );
556 g_list_append( folderGroup, folder );
564 * Get address cache of first item in list. This assumes that all items in
565 * the clipboard are located in the same cache.
566 * Enter: clipBoard Clipboard.
567 * Return: List of group or folder items added.
569 static AddressCache *addrclip_list_get_cache( AddressClipboard *clipBoard ) {
572 AddrSelectItem *item;
575 itemList = clipBoard->objectList;
577 item = itemList->data;
578 cache = addrindex_get_cache(
579 clipBoard->addressIndex, item->cacheID );
585 * Paste (copy) clipboard into address book.
586 * Enter: clipBoard Clipboard.
587 * book Target address book.
588 * folder Target folder where data is pasted, or null for root folder.
589 * Return: List of group or folder items added.
591 GList *addrclip_paste_copy(
592 AddressClipboard *clipBoard, AddressBookFile *book,
599 g_return_val_if_fail( clipBoard != NULL, NULL );
601 cache = book->addressCache;
602 if( folder == NULL ) folder = cache->rootFolder;
605 itemList = clipBoard->objectList;
606 folderGroup = addrclip_cache_add_folder(
607 cache, folder, itemList, clipBoard );
613 * Remove items that were cut from clipboard.
614 * Enter: clipBoard Clipboard.
616 void addrclip_delete_item( AddressClipboard *clipBoard ) {
617 AddrSelectItem *item;
619 AddressCache *cacheFrom;
622 /* If cutting within current cache, no deletion is necessary */
623 if( clipBoard->moveFlag ) return;
626 node = clipBoard->objectList;
629 node = g_list_next( node );
630 cacheFrom = addrindex_get_cache(
631 clipBoard->addressIndex, item->cacheID );
632 if( cacheFrom == NULL ) continue;
633 aio = addrcache_get_object( cacheFrom, item->uid );
635 if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
638 group = ( ItemGroup * ) aio;
639 group = addrcache_remove_group( cacheFrom, group );
641 addritem_free_item_group( group );
647 /* Remove persons and folders */
648 node = clipBoard->objectList;
651 node = g_list_next( node );
653 cacheFrom = addrindex_get_cache(
654 clipBoard->addressIndex, item->cacheID );
655 if( cacheFrom == NULL ) continue;
657 aio = addrcache_get_object( cacheFrom, item->uid );
659 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
662 person = ( ItemPerson * ) aio;
663 person = addrcache_remove_person( cacheFrom, person );
665 addritem_free_item_person( person );
668 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
669 ItemFolder *itemFolder;
671 itemFolder = ( ItemFolder * ) aio;
672 itemFolder = addrcache_remove_folder_delete(
673 cacheFrom, itemFolder );
674 addritem_free_item_folder( itemFolder );
681 * Paste (move) clipboard into address book.
682 * Enter: clipBoard Clipboard.
683 * book Target address book.
684 * folder Target folder where data is pasted, or null for root folder.
685 * Return: List of group or folder items added.
687 GList *addrclip_paste_cut(
688 AddressClipboard *clipBoard, AddressBookFile *book,
691 AddressCache *cache, *cacheFrom;
695 g_return_val_if_fail( clipBoard != NULL, NULL );
697 cache = book->addressCache;
698 if( folder == NULL ) folder = cache->rootFolder;
701 clipBoard->moveFlag = FALSE;
702 cacheFrom = addrclip_list_get_cache( clipBoard );
703 if( cacheFrom && cacheFrom == cache ) {
704 /* Move items between folders in same book */
705 itemList = clipBoard->objectList;
706 folderGroup = addrclip_cache_move_items(
707 cache, folder, itemList, clipBoard );
708 clipBoard->moveFlag = TRUE;
711 /* Move items across address books */
712 itemList = clipBoard->objectList;
713 folderGroup = addrclip_cache_add_folder(
714 cache, folder, itemList, clipBoard );
721 * ============================================================================
722 * Paste address only.
723 * ============================================================================
727 * Copy email addresses from specified list.
728 * Enter: cache Address cache to paste into.
729 * target Person to receive email addresses.
730 * listEMail List of email addresses.
731 * Return: Number of addresses added.
733 static gint addrclip_person_add_email(
734 AddressCache *cache, ItemPerson *target, GList *listEMail )
739 /* Copy email addresses */
743 ItemEMail *email, *newEMail;
746 newEMail = addritem_copy_item_email( email );
747 addrcache_id_email( cache, newEMail );
748 addrcache_person_add_email( cache, target, newEMail );
749 node = g_list_next( node );
756 * Paste (copy) E-Mail addresses from clipboard into specified person.
757 * Enter: aio Address item to copy from.
758 * cache Target address cache.
759 * person Target person where data is pasted.
760 * Return: Number of EMail records added.
762 static gint addrclip_copy_email_to_person(
763 AddrItemObject *aio, AddressCache *cache, ItemPerson *person )
770 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
771 ItemPerson *fromPerson;
773 fromPerson = ( ItemPerson * ) aio;
774 listEMail = fromPerson->listEMail;
775 cnt += addrclip_person_add_email(
776 cache, person, listEMail );
778 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
779 ItemEMail *email, *newEMail;
781 email = ( ItemEMail * ) aio;
782 newEMail = addritem_copy_item_email( email );
783 addrcache_id_email( cache, newEMail );
784 addrcache_person_add_email( cache, person, newEMail );
787 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
790 group = ( ItemGroup * ) aio;
791 listEMail = group->listEMail;
792 cnt += addrclip_person_add_email(
793 cache, person, listEMail );
795 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_FOLDER ) {
797 AddrItemObject *item;
800 folder = ( ItemFolder * ) aio;
801 node = folder->listPerson;
804 node = g_list_next( node );
805 cnt += addrclip_copy_email_to_person( item, cache, person );
808 node = folder->listGroup;
811 node = g_list_next( node );
812 cnt += addrclip_copy_email_to_person( item, cache, person );
815 node = folder->listFolder;
818 node = g_list_next( node );
819 cnt += addrclip_copy_email_to_person( item, cache, person );
826 * Paste (copy) E-Mail addresses from clipboard into specified person.
827 * Enter: clipBoard Clipboard.
828 * cache Target address cache.
829 * person Target person where data is pasted.
830 * Return: Number of EMail records added.
832 static gint addrclip_copyto_person(
833 AddressClipboard *clipBoard, AddressCache *cache, ItemPerson *person )
839 node = clipBoard->objectList;
841 AddressCache *cacheFrom;
842 AddrSelectItem *item;
846 node = g_list_next( node );
847 cacheFrom = addrindex_get_cache(
848 clipBoard->addressIndex, item->cacheID );
849 if( cacheFrom == NULL ) continue;
850 aio = addrcache_get_object( cacheFrom, item->uid );
852 cnt += addrclip_copy_email_to_person( aio, cache, person );
859 * Paste (copy) E-Mail addresses from clipboard into specified person.
860 * Enter: clipBoard Clipboard.
861 * book Target address book.
862 * person Target person where data is pasted.
863 * Return: Number of EMail records added.
865 gint addrclip_paste_person_copy(
866 AddressClipboard *clipBoard, AddressBookFile *book,
873 g_return_val_if_fail( clipBoard != NULL, cnt );
875 cache = book->addressCache;
877 cnt = addrclip_copyto_person( clipBoard, cache, person );
883 * Move email addresses for specified person to target person.
884 * Enter: cache Address cache to paste into.
885 * fromPerson Person supplying email addresses.
886 * target Person to receive email addresses.
887 * Return: Number of addresses moved.
889 static gint addrclip_person_move_email(
890 AddressCache *cache, ItemPerson *fromPerson, ItemPerson *target )
896 while( (node = fromPerson->listEMail) != NULL ) {
900 addrcache_person_move_email( cache, email, target );
907 * Paste (cut) E-Mail addresses from clipboard into specified person.
908 * Enter: clipBoard Clipboard.
909 * cache Target address cache.
910 * person Target person where data is pasted.
911 * Return: Number of EMail records added.
913 static gint addrclip_paste_person_move(
914 AddressClipboard *clipBoard, AddressCache *cache, ItemPerson *person )
917 AddressCache *cacheFrom;
918 AddrSelectItem *item;
924 node = clipBoard->objectList;
927 node = g_list_next( node );
928 cacheFrom = addrindex_get_cache(
929 clipBoard->addressIndex, item->cacheID );
930 if( cacheFrom == NULL ) continue;
931 aio = addrcache_get_object( cacheFrom, item->uid );
933 if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
934 ItemPerson *fromPerson;
936 fromPerson = ( ItemPerson * ) aio;
937 cnt += addrclip_person_move_email(
938 cache, fromPerson, person );
940 if( addritem_person_empty( fromPerson ) ) {
942 addrcache_remove_person(
943 cacheFrom, fromPerson );
944 if( fromPerson != NULL ) {
945 addritem_free_item_person( fromPerson );
950 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
953 email = ( ItemEMail * ) aio;
954 addrcache_person_move_email(
955 cache, email, person );
958 else if( ADDRITEM_TYPE(aio) == ITEMTYPE_GROUP ) {
961 group = ( ItemGroup * ) aio;
962 listEMail = group->listEMail;
963 cnt += addrclip_person_add_email(
964 cache, person, listEMail );
972 * Paste (cut) E-Mail addresses from clipboard into specified person.
973 * Enter: clipBoard Clipboard.
974 * book Target address book.
975 * person Target person where data is pasted.
976 * Return: Number of EMail records added.
978 gint addrclip_paste_person_cut(
979 AddressClipboard *clipBoard, AddressBookFile *book,
983 AddressCache *cache, *cacheFrom;
986 g_return_val_if_fail( clipBoard != NULL, cnt );
988 cache = book->addressCache;
990 clipBoard->moveFlag = FALSE;
991 cacheFrom = addrclip_list_get_cache( clipBoard );
992 if( cacheFrom && cacheFrom == cache ) {
993 cnt = addrclip_paste_person_move(
994 clipBoard, cache, person );
995 clipBoard->moveFlag = TRUE;
998 /* Move items across address books */
999 cnt = addrclip_copyto_person(
1000 clipBoard, cache, person );
1007 * Remove address items that were cut from clipboard. Note that that only
1008 * E-Mail items are actually deleted. Any Person items will not be deleted
1009 * (not even E-Mail items that owned by a person). Any Group or Folder
1010 * items will *NOT* be deleted.
1011 * Enter: clipBoard Clipboard.
1013 void addrclip_delete_address( AddressClipboard *clipBoard ) {
1014 AddrSelectItem *item;
1015 AddrItemObject *aio;
1016 AddressCache *cacheFrom;
1019 /* If cutting within current cache, no deletion is necessary */
1020 if( clipBoard->moveFlag ) return;
1023 node = clipBoard->objectList;
1026 node = g_list_next( node );
1027 cacheFrom = addrindex_get_cache(
1028 clipBoard->addressIndex, item->cacheID );
1029 if( cacheFrom == NULL ) continue;
1030 aio = addrcache_get_object( cacheFrom, item->uid );
1032 if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
1036 email = ( ItemEMail * ) aio;
1037 person = ( ItemPerson * ) ADDRITEM_PARENT(email);
1038 email = addrcache_person_remove_email(
1039 cacheFrom, person, email );
1041 addritem_free_item_email( email );