bookmark_xxport.cpp
00001 /* 00002 This file is part of KAddressbook. 00003 Copyright (c) 2003 Alexander Kellett <lypanov@kde.org> 00004 Tobias Koenig <tokoe@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of TQt, and distribute the resulting executable, 00022 without including the source code for TQt in the source distribution. 00023 */ 00024 00025 #include <kbookmark.h> 00026 #include <kbookmarkmanager.h> 00027 #include <kbookmarkmenu.h> 00028 #include <kbookmarkdombuilder.h> 00029 #include <klocale.h> 00030 #include <kstandarddirs.h> 00031 00032 #include "bookmark_xxport.h" 00033 00034 K_EXPORT_KADDRESSBOOK_XXFILTER( libkaddrbk_bookmark_xxport, BookmarkXXPort ) 00035 00036 BookmarkXXPort::BookmarkXXPort( KABC::AddressBook *ab, TQWidget *parent, const char *name ) 00037 : KAB::XXPort( ab, parent, name ) 00038 { 00039 createExportAction( i18n( "Export Bookmarks Menu..." ) ); 00040 } 00041 00042 bool BookmarkXXPort::exportContacts( const KABC::AddresseeList &list, const TQString& ) 00043 { 00044 TQString fileName = locateLocal( "data", "kabc/bookmarks.xml" ); 00045 00046 KBookmarkManager *mgr = KBookmarkManager::managerForFile( fileName ); 00047 KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( mgr->root(), mgr ); 00048 builder->connectImporter( this ); 00049 00050 KABC::AddresseeList::ConstIterator it; 00051 emit newFolder( i18n( "AddressBook" ), false, "" ); 00052 for ( it = list.begin(); it != list.end(); ++it ) { 00053 if ( !(*it).url().isEmpty() ) { 00054 TQString name = (*it).givenName() + " " + (*it).familyName(); 00055 emit newBookmark( name, (*it).url().url().latin1(), TQString( "" ) ); 00056 } 00057 } 00058 emit endFolder(); 00059 delete builder; 00060 mgr->save(); 00061 00062 KBookmarkMenu::DynMenuInfo menu; 00063 menu.name = i18n( "Addressbook Bookmarks" ); 00064 menu.location = fileName; 00065 menu.type = "xbel"; 00066 menu.show = true; 00067 KBookmarkMenu::setDynamicBookmarks( "kabc", menu ); 00068 00069 return true; 00070 } 00071 00072 #include "bookmark_xxport.moc"