summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-09 10:29:56 (UTC)
committer zautrix <zautrix>2004-10-09 10:29:56 (UTC)
commited1eac5e36e675b030cb5a5aa90fb2d44eb40c73 (patch) (unidiff)
tree2d4dd35819f17c4b5758b64defd40e7a4bf3cbde
parent69af2ac56474e3a1e3e59be318caf53f5d357f94 (diff)
downloadkdepimpi-ed1eac5e36e675b030cb5a5aa90fb2d44eb40c73.zip
kdepimpi-ed1eac5e36e675b030cb5a5aa90fb2d44eb40c73.tar.gz
kdepimpi-ed1eac5e36e675b030cb5a5aa90fb2d44eb40c73.tar.bz2
phone fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp1
-rw-r--r--kaddressbook/kabcore.cpp3
-rw-r--r--libkdepim/phoneaccess.cpp6
3 files changed, 8 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 1a06956..1050f55 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,170 +1,171 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28/*US 28/*US
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <kapplication.h> 34#include <kapplication.h>
35#include <kinstance.h> 35#include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "errorhandler.h" 38#include "errorhandler.h"
39*/ 39*/
40#include <qptrlist.h> 40#include <qptrlist.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qfile.h> 42#include <qfile.h>
43#include <qregexp.h>
43 44
44#include <kglobal.h> 45#include <kglobal.h>
45#include <klocale.h> 46#include <klocale.h>
46#include <kmessagebox.h> 47#include <kmessagebox.h>
47#include <kdebug.h> 48#include <kdebug.h>
48#include <libkcal/syncdefines.h> 49#include <libkcal/syncdefines.h>
49#include "addressbook.h" 50#include "addressbook.h"
50#include "resource.h" 51#include "resource.h"
51#include "vcardconverter.h" 52#include "vcardconverter.h"
52#include "vcardparser/vcardtool.h" 53#include "vcardparser/vcardtool.h"
53 54
54//US #include "addressbook.moc" 55//US #include "addressbook.moc"
55 56
56using namespace KABC; 57using namespace KABC;
57 58
58struct AddressBook::AddressBookData 59struct AddressBook::AddressBookData
59{ 60{
60 Addressee::List mAddressees; 61 Addressee::List mAddressees;
61 Addressee::List mRemovedAddressees; 62 Addressee::List mRemovedAddressees;
62 Field::List mAllFields; 63 Field::List mAllFields;
63 KConfig *mConfig; 64 KConfig *mConfig;
64 KRES::Manager<Resource> *mManager; 65 KRES::Manager<Resource> *mManager;
65//US ErrorHandler *mErrorHandler; 66//US ErrorHandler *mErrorHandler;
66}; 67};
67 68
68struct AddressBook::Iterator::IteratorData 69struct AddressBook::Iterator::IteratorData
69{ 70{
70 Addressee::List::Iterator mIt; 71 Addressee::List::Iterator mIt;
71}; 72};
72 73
73struct AddressBook::ConstIterator::ConstIteratorData 74struct AddressBook::ConstIterator::ConstIteratorData
74{ 75{
75 Addressee::List::ConstIterator mIt; 76 Addressee::List::ConstIterator mIt;
76}; 77};
77 78
78AddressBook::Iterator::Iterator() 79AddressBook::Iterator::Iterator()
79{ 80{
80 d = new IteratorData; 81 d = new IteratorData;
81} 82}
82 83
83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 84AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
84{ 85{
85 d = new IteratorData; 86 d = new IteratorData;
86 d->mIt = i.d->mIt; 87 d->mIt = i.d->mIt;
87} 88}
88 89
89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 90AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
90{ 91{
91 if( this == &i ) return *this; // guard against self assignment 92 if( this == &i ) return *this; // guard against self assignment
92 delete d; // delete the old data the Iterator was completely constructed before 93 delete d; // delete the old data the Iterator was completely constructed before
93 d = new IteratorData; 94 d = new IteratorData;
94 d->mIt = i.d->mIt; 95 d->mIt = i.d->mIt;
95 return *this; 96 return *this;
96} 97}
97 98
98AddressBook::Iterator::~Iterator() 99AddressBook::Iterator::~Iterator()
99{ 100{
100 delete d; 101 delete d;
101} 102}
102 103
103const Addressee &AddressBook::Iterator::operator*() const 104const Addressee &AddressBook::Iterator::operator*() const
104{ 105{
105 return *(d->mIt); 106 return *(d->mIt);
106} 107}
107 108
108Addressee &AddressBook::Iterator::operator*() 109Addressee &AddressBook::Iterator::operator*()
109{ 110{
110 return *(d->mIt); 111 return *(d->mIt);
111} 112}
112 113
113Addressee *AddressBook::Iterator::operator->() 114Addressee *AddressBook::Iterator::operator->()
114{ 115{
115 return &(*(d->mIt)); 116 return &(*(d->mIt));
116} 117}
117 118
118AddressBook::Iterator &AddressBook::Iterator::operator++() 119AddressBook::Iterator &AddressBook::Iterator::operator++()
119{ 120{
120 (d->mIt)++; 121 (d->mIt)++;
121 return *this; 122 return *this;
122} 123}
123 124
124AddressBook::Iterator &AddressBook::Iterator::operator++(int) 125AddressBook::Iterator &AddressBook::Iterator::operator++(int)
125{ 126{
126 (d->mIt)++; 127 (d->mIt)++;
127 return *this; 128 return *this;
128} 129}
129 130
130AddressBook::Iterator &AddressBook::Iterator::operator--() 131AddressBook::Iterator &AddressBook::Iterator::operator--()
131{ 132{
132 (d->mIt)--; 133 (d->mIt)--;
133 return *this; 134 return *this;
134} 135}
135 136
136AddressBook::Iterator &AddressBook::Iterator::operator--(int) 137AddressBook::Iterator &AddressBook::Iterator::operator--(int)
137{ 138{
138 (d->mIt)--; 139 (d->mIt)--;
139 return *this; 140 return *this;
140} 141}
141 142
142bool AddressBook::Iterator::operator==( const Iterator &it ) 143bool AddressBook::Iterator::operator==( const Iterator &it )
143{ 144{
144 return ( d->mIt == it.d->mIt ); 145 return ( d->mIt == it.d->mIt );
145} 146}
146 147
147bool AddressBook::Iterator::operator!=( const Iterator &it ) 148bool AddressBook::Iterator::operator!=( const Iterator &it )
148{ 149{
149 return ( d->mIt != it.d->mIt ); 150 return ( d->mIt != it.d->mIt );
150} 151}
151 152
152 153
153AddressBook::ConstIterator::ConstIterator() 154AddressBook::ConstIterator::ConstIterator()
154{ 155{
155 d = new ConstIteratorData; 156 d = new ConstIteratorData;
156} 157}
157 158
158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 159AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
159{ 160{
160 d = new ConstIteratorData; 161 d = new ConstIteratorData;
161 d->mIt = i.d->mIt; 162 d->mIt = i.d->mIt;
162} 163}
163 164
164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 165AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
165{ 166{
166 if( this == &i ) return *this; // guard for self assignment 167 if( this == &i ) return *this; // guard for self assignment
167 delete d; // delete the old data because the Iterator was really constructed before 168 delete d; // delete the old data because the Iterator was really constructed before
168 d = new ConstIteratorData; 169 d = new ConstIteratorData;
169 d->mIt = i.d->mIt; 170 d->mIt = i.d->mIt;
170 return *this; 171 return *this;
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index efcd492..7ec3fca 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2684,215 +2684,216 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2684 inL = local->findByUid( uid ); 2684 inL = local->findByUid( uid );
2685 inR = remote->findByUid( uid ); 2685 inR = remote->findByUid( uid );
2686 if ( inR.isEmpty() ) { 2686 if ( inR.isEmpty() ) {
2687 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2687 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2688 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2688 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2689 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2689 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2690 local->removeAddressee( inL ); 2690 local->removeAddressee( inL );
2691 ++deletedAddresseeL; 2691 ++deletedAddresseeL;
2692 } else { 2692 } else {
2693 if ( ! syncManager->mWriteBackExistingOnly ) { 2693 if ( ! syncManager->mWriteBackExistingOnly ) {
2694 inL.removeID(mCurrentSyncDevice ); 2694 inL.removeID(mCurrentSyncDevice );
2695 ++addedAddresseeR; 2695 ++addedAddresseeR;
2696 inL.setRevision( modifiedCalendar ); 2696 inL.setRevision( modifiedCalendar );
2697 local->insertAddressee( inL, false ); 2697 local->insertAddressee( inL, false );
2698 inR = inL; 2698 inR = inL;
2699 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2699 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2700 inR.setResource( 0 ); 2700 inR.setResource( 0 );
2701 remote->insertAddressee( inR, false ); 2701 remote->insertAddressee( inR, false );
2702 } 2702 }
2703 } 2703 }
2704 } else { 2704 } else {
2705 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2705 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2706 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2706 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2707 local->removeAddressee( inL ); 2707 local->removeAddressee( inL );
2708 ++deletedAddresseeL; 2708 ++deletedAddresseeL;
2709 } else { 2709 } else {
2710 if ( ! syncManager->mWriteBackExistingOnly ) { 2710 if ( ! syncManager->mWriteBackExistingOnly ) {
2711 ++addedAddresseeR; 2711 ++addedAddresseeR;
2712 inL.setRevision( modifiedCalendar ); 2712 inL.setRevision( modifiedCalendar );
2713 local->insertAddressee( inL, false ); 2713 local->insertAddressee( inL, false );
2714 inR = inL; 2714 inR = inL;
2715 inR.setResource( 0 ); 2715 inR.setResource( 0 );
2716 remote->insertAddressee( inR, false ); 2716 remote->insertAddressee( inR, false );
2717 } 2717 }
2718 } 2718 }
2719 } 2719 }
2720 } 2720 }
2721 } 2721 }
2722 ++incCounter; 2722 ++incCounter;
2723 } 2723 }
2724 el.clear(); 2724 el.clear();
2725 syncManager->hideProgressBar(); 2725 syncManager->hideProgressBar();
2726 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2726 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2727 // get rid of micro seconds 2727 // get rid of micro seconds
2728 QTime t = mLastAddressbookSync.time(); 2728 QTime t = mLastAddressbookSync.time();
2729 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2729 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2730 addresseeLSync.setRevision( mLastAddressbookSync ); 2730 addresseeLSync.setRevision( mLastAddressbookSync );
2731 addresseeRSync.setRevision( mLastAddressbookSync ); 2731 addresseeRSync.setRevision( mLastAddressbookSync );
2732 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2732 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2733 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2733 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2734 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2734 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2735 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2735 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2736 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2736 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2737 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2737 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2738 addresseeRSync.setNote( "" ) ; 2738 addresseeRSync.setNote( "" ) ;
2739 addresseeLSync.setNote( "" ); 2739 addresseeLSync.setNote( "" );
2740 2740
2741 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2741 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2742 remote->insertAddressee( addresseeRSync, false ); 2742 remote->insertAddressee( addresseeRSync, false );
2743 local->insertAddressee( addresseeLSync, false ); 2743 local->insertAddressee( addresseeLSync, false );
2744 QString mes; 2744 QString mes;
2745 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2745 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2746 if ( syncManager->mShowSyncSummary ) { 2746 if ( syncManager->mShowSyncSummary ) {
2747 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2747 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2748 } 2748 }
2749 qDebug( mes ); 2749 qDebug( mes );
2750 return syncOK; 2750 return syncOK;
2751} 2751}
2752 2752
2753 2753
2754//this is a overwritten callbackmethods from the syncinterface 2754//this is a overwritten callbackmethods from the syncinterface
2755bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2755bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2756{ 2756{
2757 2757
2758 //pending prepare addresseeview for output 2758 //pending prepare addresseeview for output
2759 //pending detect, if remote file has REV field. if not switch to external sync 2759 //pending detect, if remote file has REV field. if not switch to external sync
2760 mGlobalSyncMode = SYNC_MODE_NORMAL; 2760 mGlobalSyncMode = SYNC_MODE_NORMAL;
2761 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2761 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2762 2762
2763 AddressBook abLocal(filename,"syncContact"); 2763 AddressBook abLocal(filename,"syncContact");
2764 bool syncOK = false; 2764 bool syncOK = false;
2765 if ( abLocal.load() ) { 2765 if ( abLocal.load() ) {
2766 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2766 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2767 bool external = false; 2767 bool external = false;
2768 bool isXML = false; 2768 bool isXML = false;
2769 if ( filename.right(4) == ".xml") { 2769 if ( filename.right(4) == ".xml") {
2770 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2770 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2771 isXML = true; 2771 isXML = true;
2772 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2772 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2773 } else { 2773 } else {
2774 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2774 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2775 if ( ! lse.isEmpty() ) { 2775 if ( ! lse.isEmpty() ) {
2776 if ( lse.familyName().left(4) == "!E: " ) 2776 if ( lse.familyName().left(4) == "!E: " )
2777 external = true; 2777 external = true;
2778 } else { 2778 } else {
2779 bool found = false; 2779 bool found = false;
2780 AddressBook::Iterator it; 2780 AddressBook::Iterator it;
2781 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2781 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2782 if ( (*it).revision().date().year() > 2003 ) { 2782 if ( (*it).revision().date().year() > 2003 ) {
2783 found = true; 2783 found = true;
2784 break; 2784 break;
2785 } 2785 }
2786 } 2786 }
2787 external = ! found; 2787 external = ! found;
2788 } 2788 }
2789 2789
2790 if ( external ) { 2790 if ( external ) {
2791 qDebug("Setting vcf mode to external "); 2791 qDebug("Setting vcf mode to external ");
2792 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2792 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2793 AddressBook::Iterator it; 2793 AddressBook::Iterator it;
2794 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2794 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2795 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2795 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2796 (*it).computeCsum( mCurrentSyncDevice ); 2796 (*it).computeCsum( mCurrentSyncDevice );
2797 } 2797 }
2798 } 2798 }
2799 } 2799 }
2800 //AddressBook::Iterator it; 2800 //AddressBook::Iterator it;
2801 //QStringList vcards; 2801 //QStringList vcards;
2802 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2802 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2803 // qDebug("Name %s ", (*it).familyName().latin1()); 2803 // qDebug("Name %s ", (*it).familyName().latin1());
2804 //} 2804 //}
2805 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2805 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2806 if ( syncOK ) { 2806 if ( syncOK ) {
2807 if ( syncManager->mWriteBackFile ) 2807 if ( syncManager->mWriteBackFile )
2808 { 2808 {
2809 if ( external ) 2809 if ( external )
2810 abLocal.removeSyncAddressees( !isXML); 2810 abLocal.removeSyncAddressees( !isXML);
2811 qDebug("Saving remote AB "); 2811 qDebug("Saving remote AB ");
2812 abLocal.saveAB(); 2812 if ( ! abLocal.saveAB())
2813 qDebug("Error writing back AB to file ");
2813 if ( isXML ) { 2814 if ( isXML ) {
2814 // afterwrite processing 2815 // afterwrite processing
2815 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2816 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2816 } 2817 }
2817 } 2818 }
2818 } 2819 }
2819 setModified(); 2820 setModified();
2820 2821
2821 } 2822 }
2822 if ( syncOK ) 2823 if ( syncOK )
2823 mViewManager->refreshView(); 2824 mViewManager->refreshView();
2824 return syncOK; 2825 return syncOK;
2825#if 0 2826#if 0
2826 2827
2827 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2828 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2828 getEventViewerDialog()->setSyncMode( true ); 2829 getEventViewerDialog()->setSyncMode( true );
2829 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2830 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2830 getEventViewerDialog()->setSyncMode( false ); 2831 getEventViewerDialog()->setSyncMode( false );
2831 if ( syncOK ) { 2832 if ( syncOK ) {
2832 if ( KOPrefs::instance()->mWriteBackFile ) 2833 if ( KOPrefs::instance()->mWriteBackFile )
2833 { 2834 {
2834 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2835 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2835 storage->save(); 2836 storage->save();
2836 } 2837 }
2837 } 2838 }
2838 setModified(); 2839 setModified();
2839 } 2840 }
2840 2841
2841#endif 2842#endif
2842} 2843}
2843 2844
2844 2845
2845//this is a overwritten callbackmethods from the syncinterface 2846//this is a overwritten callbackmethods from the syncinterface
2846bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2847bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2847{ 2848{
2848 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2849 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2849 2850
2850 AddressBook abLocal( resource,"syncContact"); 2851 AddressBook abLocal( resource,"syncContact");
2851 bool syncOK = false; 2852 bool syncOK = false;
2852 if ( abLocal.load() ) { 2853 if ( abLocal.load() ) {
2853 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2854 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2854 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2855 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2855 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2856 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2856 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2857 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2857 if ( syncOK ) { 2858 if ( syncOK ) {
2858 if ( syncManager->mWriteBackFile ) { 2859 if ( syncManager->mWriteBackFile ) {
2859 abLocal.saveAB(); 2860 abLocal.saveAB();
2860 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2861 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2861 } 2862 }
2862 } 2863 }
2863 setModified(); 2864 setModified();
2864 } 2865 }
2865 if ( syncOK ) 2866 if ( syncOK )
2866 mViewManager->refreshView(); 2867 mViewManager->refreshView();
2867 return syncOK; 2868 return syncOK;
2868 2869
2869} 2870}
2870 2871
2871void KABCore::getFile( bool success ) 2872void KABCore::getFile( bool success )
2872{ 2873{
2873 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2874 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2874 if ( ! success ) { 2875 if ( ! success ) {
2875 setCaption( i18n("Error receiving file. Nothing changed!") ); 2876 setCaption( i18n("Error receiving file. Nothing changed!") );
2876 return; 2877 return;
2877 } 2878 }
2878 mAddressBook->importFromFile( sentSyncFile() ); 2879 mAddressBook->importFromFile( sentSyncFile() );
2879 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 2880 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2880 mViewManager->refreshView(); 2881 mViewManager->refreshView();
2881} 2882}
2882void KABCore::syncFileRequest() 2883void KABCore::syncFileRequest()
2883{ 2884{
2884 mAddressBook->export2File( sentSyncFile() ); 2885 mAddressBook->export2File( sentSyncFile() );
2885} 2886}
2886QString KABCore::sentSyncFile() 2887QString KABCore::sentSyncFile()
2887{ 2888{
2888#ifdef _WIN32_ 2889#ifdef _WIN32_
2889 return locateLocal( "tmp", "copysyncab.vcf" ); 2890 return locateLocal( "tmp", "copysyncab.vcf" );
2890#else 2891#else
2891 return QString( "/tmp/copysyncab.vcf" ); 2892 return QString( "/tmp/copysyncab.vcf" );
2892#endif 2893#endif
2893} 2894}
2894 2895
2895void KABCore::setCaptionBack() 2896void KABCore::setCaptionBack()
2896{ 2897{
2897 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2898 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2898} 2899}
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp
index 357cd39..fe914dd 100644
--- a/libkdepim/phoneaccess.cpp
+++ b/libkdepim/phoneaccess.cpp
@@ -6,142 +6,146 @@
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qfile.h> 27#include <qfile.h>
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qtextcodec.h> 29#include <qtextcodec.h>
30#include <qdir.h> 30#include <qdir.h>
31#include <kmessagebox.h> 31#include <kmessagebox.h>
32#include <stdlib.h> 32#include <stdlib.h>
33#include "phoneaccess.h" 33#include "phoneaccess.h"
34 34
35void PhoneAccess::writeConfig( QString device, QString connection, QString model ) 35void PhoneAccess::writeConfig( QString device, QString connection, QString model )
36{ 36{
37#ifdef _WIN32_ 37#ifdef _WIN32_
38 QString fileName = qApp->applicationDirPath () +"\\gammurc"; 38 QString fileName = qApp->applicationDirPath () +"\\gammurc";
39#else 39#else
40 QString fileName = QDir::homeDirPath() +"/.gammurc"; 40 QString fileName = QDir::homeDirPath() +"/.gammurc";
41#endif 41#endif
42 //qDebug("save %d ", load ); 42 //qDebug("save %d ", load );
43 QString content = "[gammu]\n";; 43 QString content = "[gammu]\n";;
44 bool write = false; 44 bool write = false;
45 bool addPort = true, addConnection = true, addModel = true; 45 bool addPort = true, addConnection = true, addModel = true;
46 QFile file( fileName ); 46 QFile file( fileName );
47 if ( QFile::exists( fileName) ) { 47 if ( QFile::exists( fileName) ) {
48 if (!file.open( IO_ReadOnly ) ) { 48 if (!file.open( IO_ReadOnly ) ) {
49 qDebug("Error: cannot open %s ", fileName.latin1() ); 49 qDebug("Error: cannot open %s ", fileName.latin1() );
50 return; 50 return;
51 } 51 }
52 QString line; 52 QString line;
53 while ( file.readLine( line, 1024 ) > 0 ) { 53 while ( file.readLine( line, 1024 ) > 0 ) {
54 //qDebug("*%s* ", line.latin1() ); 54 //qDebug("*%s* ", line.latin1() );
55 if ( line.left(7 ) == "[gammu]" ) { 55 if ( line.left(7 ) == "[gammu]" ) {
56 ; 56 ;
57 } else 57 } else
58 if ( line.left(4 ) == "port" ) { 58 if ( line.left(4 ) == "port" ) {
59 if ( line == "port = " + device+"\n" ) { 59 if ( line == "port = " + device+"\n" ) {
60 content += line ; 60 content += line ;
61 addPort = false; 61 addPort = false;
62 //qDebug("port found" ); 62 //qDebug("port found" );
63 } 63 }
64 64
65 } else if ( line.left(5 ) == "model" ) { 65 } else if ( line.left(5 ) == "model" ) {
66 if ( line == "model = " + model +"\n") { 66 if ( line == "model = " + model +"\n") {
67 content += line ; 67 content += line ;
68 addModel = false; 68 addModel = false;
69 //qDebug("model found" ); 69 //qDebug("model found" );
70 } 70 }
71 71
72 } else if ( line.left( 10 ) == "connection" ) { 72 } else if ( line.left( 10 ) == "connection" ) {
73 if ( line == "connection = " + connection +"\n") { 73 if ( line == "connection = " + connection +"\n") {
74 addConnection = false; 74 addConnection = false;
75 content += line ; 75 content += line ;
76 //qDebug("con found" ); 76 //qDebug("con found" );
77 } 77 }
78 78
79 } else { 79 } else {
80 content += line ; 80 content += line ;
81 } 81 }
82 } 82 }
83 file.close(); 83 file.close();
84 } else { 84 } else {
85 if ( ! connection.isEmpty() ) { 85 if ( ! connection.isEmpty() ) {
86 addConnection = true; 86 addConnection = true;
87 } 87 }
88 if ( ! device.isEmpty() ) { 88 if ( ! device.isEmpty() ) {
89 addPort = true; 89 addPort = true;
90 90
91 } 91 }
92 if ( ! model.isEmpty() ) { 92 if ( ! model.isEmpty() ) {
93 addModel = true; 93 addModel = true;
94 } 94 }
95 } 95 }
96 96
97 if ( addConnection ) { 97 if ( addConnection ) {
98 write = true; 98 write = true;
99 content += "connection = "; 99 content += "connection = ";
100 content += connection; 100 content += connection;
101 content += "\n"; 101 content += "\n";
102 } 102 }
103 if ( addPort ) { 103 if ( addPort ) {
104 write = true; 104 write = true;
105 content += "port = "; 105 content += "port = ";
106 content += device; 106 content += device;
107 content += "\n"; 107 content += "\n";
108 108
109 } 109 }
110 if ( addModel ) { 110 if ( addModel ) {
111 write = true; 111 write = true;
112 content += "model = "; 112 content += "model = ";
113 content += model; 113 content += model;
114 content += "\n"; 114 content += "\n";
115 } 115 }
116 if ( write ) { 116 if ( write ) {
117 if (!file.open( IO_WriteOnly ) ) { 117 if (!file.open( IO_WriteOnly ) ) {
118 qDebug("Error: cannot write file %s ", fileName.latin1() ); 118 qDebug("Error: cannot write file %s ", fileName.latin1() );
119 return; 119 return;
120 } 120 }
121 qDebug("Writing file %s ", fileName.latin1() ); 121 qDebug("Writing file %s ", fileName.latin1() );
122 QTextStream ts( &file ); 122 QTextStream ts( &file );
123 ts << content ; 123 ts << content ;
124 file.close(); 124 file.close();
125 } 125 }
126 126
127} 127}
128 128
129 129
130bool PhoneAccess::writeToPhone( QString fileName) 130bool PhoneAccess::writeToPhone( QString fileName)
131{ 131{
132 132
133#ifdef DESKTOP_VERSION 133#ifdef DESKTOP_VERSION
134#ifdef _WIN32_
135 QString command ="kammu --restore " + fileName ;
136#else
134 QString command ="./kammu --restore " + fileName ; 137 QString command ="./kammu --restore " + fileName ;
138#endif
135#else 139#else
136 QString command ="kammu --restore " + fileName ; 140 QString command ="kammu --restore " + fileName ;
137#endif 141#endif
138 int ret; 142 int ret;
139 while ( (ret = system ( command.latin1())) != 0 ) { 143 while ( (ret = system ( command.latin1())) != 0 ) {
140 qDebug("Error S::command returned %d. asking users", ret); 144 qDebug("Error S::command returned %d.", ret);
141 int retval = KMessageBox::warningContinueCancel(0, 145 int retval = KMessageBox::warningContinueCancel(0,
142 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); 146 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel"));
143 if ( retval != KMessageBox::Continue ) 147 if ( retval != KMessageBox::Continue )
144 return false; 148 return false;
145 } 149 }
146 return true; 150 return true;
147} 151}