summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp1
-rw-r--r--kaddressbook/kabcore.cpp30
-rw-r--r--kaddressbook/kabcore.h1
-rw-r--r--kmicromail/libetpan/mime/mailmime_decode.c8
4 files changed, 27 insertions, 13 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 78eaf65..dd2121a 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -1,167 +1,168 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qcombobox.h> 27#include <qcombobox.h>
28 28
29#include <kdialog.h> 29#include <kdialog.h>
30#include <klineedit.h> 30#include <klineedit.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include "kabprefs.h" 34#include "kabprefs.h"
35 35
36#include "incsearchwidget.h" 36#include "incsearchwidget.h"
37 37
38IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 38IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
39 : QWidget( parent, name ) 39 : QWidget( parent, name )
40{ 40{
41#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
42//US setCaption( i18n( "Incremental Search" ) ); 42//US setCaption( i18n( "Incremental Search" ) );
43#endif //KAB_EMBEDDED 43#endif //KAB_EMBEDDED
44 44
45 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 45 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() );
46 46
47#ifdef DESKTOP_VERSION 47#ifdef DESKTOP_VERSION
48 QLabel *label = new QLabel( i18n( "Search:" ), this ); 48 QLabel *label = new QLabel( i18n( "Search:" ), this );
49 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 49 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
50 layout->addWidget( label ); 50 layout->addWidget( label );
51#endif //KAB_EMBEDDED 51#endif //KAB_EMBEDDED
52 52
53 mSearchText = new KLineEdit( this ); 53 mSearchText = new KLineEdit( this );
54 layout->addWidget( mSearchText ); 54 layout->addWidget( mSearchText );
55// #ifdef KAB_EMBEDDED 55// #ifdef KAB_EMBEDDED
56// if (KGlobal::getOrientation() == KGlobal::Portrait) 56// if (KGlobal::getOrientation() == KGlobal::Portrait)
57// mSearchText->setMaximumWidth(30); 57// mSearchText->setMaximumWidth(30);
58// #endif //KAB_EMBEDDED 58// #endif //KAB_EMBEDDED
59 //mSearchText->setMaximumWidth(60);
59 60
60 61
61 mFieldCombo = new QComboBox( false, this ); 62 mFieldCombo = new QComboBox( false, this );
62 layout->addWidget( mFieldCombo ); 63 layout->addWidget( mFieldCombo );
63 mFieldCombo->setMaximumHeight( 34 ); 64 mFieldCombo->setMaximumHeight( 34 );
64 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 65 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
65 66
66// #ifndef KAB_EMBEDDED 67// #ifndef KAB_EMBEDDED
67// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 68// resize( QSize(420, 50).expandedTo( sizeHint() ) );
68// #else //KAB_EMBEDDED 69// #else //KAB_EMBEDDED
69// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 70// resize( QSize(30, 10).expandedTo( sizeHint() ) );
70// #endif //KAB_EMBEDDED 71// #endif //KAB_EMBEDDED
71 72
72 73
73 // for performance reasons, we do a search on the pda only after return is pressed 74 // for performance reasons, we do a search on the pda only after return is pressed
74 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 75 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
75 SLOT( announceDoSearch2() ) ); 76 SLOT( announceDoSearch2() ) );
76 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 77 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
77 SLOT( announceDoSearch2() ) ); 78 SLOT( announceDoSearch2() ) );
78 79
79 connect( mSearchText, SIGNAL( returnPressed() ), 80 connect( mSearchText, SIGNAL( returnPressed() ),
80 SLOT( announceDoSearch() ) ); 81 SLOT( announceDoSearch() ) );
81 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
82 SLOT( announceFieldChanged() ) ); 83 SLOT( announceFieldChanged() ) );
83 84
84 85
85 86
86 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); 87 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
87 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); 88 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
88 89
89 90
90 setFocusProxy( mSearchText ); 91 setFocusProxy( mSearchText );
91} 92}
92 93
93IncSearchWidget::~IncSearchWidget() 94IncSearchWidget::~IncSearchWidget()
94{ 95{
95 96
96} 97}
97void IncSearchWidget::announceDoSearch2() 98void IncSearchWidget::announceDoSearch2()
98{ 99{
99 if ( KABPrefs::instance()->mSearchWithReturn ) 100 if ( KABPrefs::instance()->mSearchWithReturn )
100 return; 101 return;
101 emit doSearch( mSearchText->text() ); 102 emit doSearch( mSearchText->text() );
102 //qDebug("emit dosreach "); 103 //qDebug("emit dosreach ");
103} 104}
104 105
105void IncSearchWidget::announceDoSearch() 106void IncSearchWidget::announceDoSearch()
106{ 107{
107 108
108 emit doSearch( mSearchText->text() ); 109 emit doSearch( mSearchText->text() );
109 // qDebug("emit dosreach "); 110 // qDebug("emit dosreach ");
110} 111}
111 112
112void IncSearchWidget::announceFieldChanged() 113void IncSearchWidget::announceFieldChanged()
113{ 114{
114 emit fieldChanged(); 115 emit fieldChanged();
115} 116}
116 117
117void IncSearchWidget::setFields( const KABC::Field::List &list ) 118void IncSearchWidget::setFields( const KABC::Field::List &list )
118{ 119{
119 120
120 mFieldCombo->clear(); 121 mFieldCombo->clear();
121 mFieldCombo->insertItem( i18n( "All Fields" ) ); 122 mFieldCombo->insertItem( i18n( "All Fields" ) );
122 QFontMetrics fm ( mFieldCombo->font() ); 123 QFontMetrics fm ( mFieldCombo->font() );
123 int wid = fm.width(i18n( "All Fields" ) ); 124 int wid = fm.width(i18n( "All Fields" ) );
124 int max = wid; 125 int max = wid;
125 126
126 KABC::Field::List::ConstIterator it; 127 KABC::Field::List::ConstIterator it;
127 for ( it = list.begin(); it != list.end(); ++it ) { 128 for ( it = list.begin(); it != list.end(); ++it ) {
128 mFieldCombo->insertItem( (*it)->label() ); 129 mFieldCombo->insertItem( (*it)->label() );
129 // wid = fm.width((*it)->label() ); 130 // wid = fm.width((*it)->label() );
130 //if ( wid > max ) 131 //if ( wid > max )
131 // max = wid; 132 // max = wid;
132 } 133 }
133 134
134 mFieldList = list; 135 mFieldList = list;
135 136
136 announceDoSearch(); 137 announceDoSearch();
137 announceFieldChanged(); 138 announceFieldChanged();
138 mFieldCombo->setMaximumWidth( wid+60 ); 139 mFieldCombo->setMaximumWidth( wid+60 );
139} 140}
140 141
141KABC::Field::List IncSearchWidget::fields() const 142KABC::Field::List IncSearchWidget::fields() const
142{ 143{
143 return mFieldList; 144 return mFieldList;
144} 145}
145 146
146KABC::Field *IncSearchWidget::currentField()const 147KABC::Field *IncSearchWidget::currentField()const
147{ 148{
148 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 149 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
149 return 0; // for error or 'use all fields' 150 return 0; // for error or 'use all fields'
150 else 151 else
151 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 152 return mFieldList[ mFieldCombo->currentItem() - 1 ];
152} 153}
153 154
154void IncSearchWidget::setCurrentItem( int pos ) 155void IncSearchWidget::setCurrentItem( int pos )
155{ 156{
156 mFieldCombo->setCurrentItem( pos ); 157 mFieldCombo->setCurrentItem( pos );
157 announceFieldChanged(); 158 announceFieldChanged();
158} 159}
159 160
160int IncSearchWidget::currentItem() const 161int IncSearchWidget::currentItem() const
161{ 162{
162 163
163 return mFieldCombo->currentItem(); 164 return mFieldCombo->currentItem();
164} 165}
165#ifndef KAB_EMBEDDED 166#ifndef KAB_EMBEDDED
166#include "incsearchwidget.moc" 167#include "incsearchwidget.moc"
167#endif //KAB_EMBEDDED 168#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7acf1ee..a6fc677 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1566 +1,1578 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include <kcmultidialog.h> 154#include <kcmultidialog.h>
155 155
156#ifdef _WIN32_ 156#ifdef _WIN32_
157 157
158#include "kaimportoldialog.h" 158#include "kaimportoldialog.h"
159#else 159#else
160#include <unistd.h> 160#include <unistd.h>
161#endif 161#endif
162// sync includes 162// sync includes
163#include <libkdepim/ksyncprofile.h> 163#include <libkdepim/ksyncprofile.h>
164#include <libkdepim/ksyncprefsdialog.h> 164#include <libkdepim/ksyncprefsdialog.h>
165 165
166 166
167class KABCatPrefs : public QDialog 167class KABCatPrefs : public QDialog
168{ 168{
169 public: 169 public:
170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
171 QDialog( parent, name, true ) 171 QDialog( parent, name, true )
172 { 172 {
173 setCaption( i18n("Manage new Categories") ); 173 setCaption( i18n("Manage new Categories") );
174 QVBoxLayout* lay = new QVBoxLayout( this ); 174 QVBoxLayout* lay = new QVBoxLayout( this );
175 lay->setSpacing( 3 ); 175 lay->setSpacing( 3 );
176 lay->setMargin( 3 ); 176 lay->setMargin( 3 );
177 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 177 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
178 lay->addWidget( lab ); 178 lay->addWidget( lab );
179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
180 lay->addWidget( format ); 180 lay->addWidget( format );
181 format->setExclusive ( true ) ; 181 format->setExclusive ( true ) ;
182 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 182 addCatBut = new QRadioButton(i18n("Add to category list"), format );
183 new QRadioButton(i18n("Remove from addressees"), format ); 183 new QRadioButton(i18n("Remove from addressees"), format );
184 addCatBut->setChecked( true ); 184 addCatBut->setChecked( true );
185 QPushButton * ok = new QPushButton( i18n("OK"), this ); 185 QPushButton * ok = new QPushButton( i18n("OK"), this );
186 lay->addWidget( ok ); 186 lay->addWidget( ok );
187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
188 lay->addWidget( cancel ); 188 lay->addWidget( cancel );
189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
191 resize( 200, 200 ); 191 resize( 200, 200 );
192 } 192 }
193 193
194 bool addCat() { return addCatBut->isChecked(); } 194 bool addCat() { return addCatBut->isChecked(); }
195private: 195private:
196 QRadioButton* addCatBut; 196 QRadioButton* addCatBut;
197}; 197};
198 198
199 199
200 200
201class KAex2phonePrefs : public QDialog 201class KAex2phonePrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Export to phone options") ); 207 setCaption( i18n("Export to phone options") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel *lab; 211 QLabel *lab;
212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
213 lab->setAlignment (AlignHCenter ); 213 lab->setAlignment (AlignHCenter );
214 QHBox* temphb; 214 QHBox* temphb;
215 temphb = new QHBox( this ); 215 temphb = new QHBox( this );
216 new QLabel( i18n("I/O device: "), temphb ); 216 new QLabel( i18n("I/O device: "), temphb );
217 mPhoneDevice = new QLineEdit( temphb); 217 mPhoneDevice = new QLineEdit( temphb);
218 lay->addWidget( temphb ); 218 lay->addWidget( temphb );
219 temphb = new QHBox( this ); 219 temphb = new QHBox( this );
220 new QLabel( i18n("Connection: "), temphb ); 220 new QLabel( i18n("Connection: "), temphb );
221 mPhoneConnection = new QLineEdit( temphb); 221 mPhoneConnection = new QLineEdit( temphb);
222 lay->addWidget( temphb ); 222 lay->addWidget( temphb );
223 temphb = new QHBox( this ); 223 temphb = new QHBox( this );
224 new QLabel( i18n("Model(opt.): "), temphb ); 224 new QLabel( i18n("Model(opt.): "), temphb );
225 mPhoneModel = new QLineEdit( temphb); 225 mPhoneModel = new QLineEdit( temphb);
226 lay->addWidget( temphb ); 226 lay->addWidget( temphb );
227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
228 // lay->addWidget( mWriteToSim ); 228 // lay->addWidget( mWriteToSim );
229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
230 lab->setAlignment (AlignHCenter ); 230 lab->setAlignment (AlignHCenter );
231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
232 lay->addWidget( ok ); 232 lay->addWidget( ok );
233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
234 lay->addWidget( cancel ); 234 lay->addWidget( cancel );
235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
237 resize( 220, 240 ); 237 resize( 220, 240 );
238 238
239 } 239 }
240 240
241public: 241public:
242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
243 QCheckBox* mWriteToSim; 243 QCheckBox* mWriteToSim;
244}; 244};
245 245
246 246
247bool pasteWithNewUid = true; 247bool pasteWithNewUid = true;
248 248
249#ifdef KAB_EMBEDDED 249#ifdef KAB_EMBEDDED
250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
254#else //KAB_EMBEDDED 254#else //KAB_EMBEDDED
255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
258 mReadWrite( readWrite ), mModified( false ) 258 mReadWrite( readWrite ), mModified( false )
259#endif //KAB_EMBEDDED 259#endif //KAB_EMBEDDED
260{ 260{
261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
262 // syncManager->setBlockSave(false); 262 // syncManager->setBlockSave(false);
263 mMiniSplitter = 0; 263 mMiniSplitter = 0;
264 mExtensionBarSplitter = 0; 264 mExtensionBarSplitter = 0;
265 mIsPart = !parent->inherits( "KAddressBookMain" ); 265 mIsPart = !parent->inherits( "KAddressBookMain" );
266 mAddressBook = KABC::StdAddressBook::self(); 266 mAddressBook = KABC::StdAddressBook::self();
267 KABC::StdAddressBook::setAutomaticSave( false ); 267 KABC::StdAddressBook::setAutomaticSave( false );
268 268
269#ifndef KAB_EMBEDDED 269#ifndef KAB_EMBEDDED
270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
271#endif //KAB_EMBEDDED 271#endif //KAB_EMBEDDED
272 272
273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
274 SLOT( addressBookChanged() ) ); 274 SLOT( addressBookChanged() ) );
275 275
276#if 0 276#if 0
277 // LP moved to addressbook init method 277 // LP moved to addressbook init method
278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
279 "X-Department", "KADDRESSBOOK" ); 279 "X-Department", "KADDRESSBOOK" );
280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
281 "X-Profession", "KADDRESSBOOK" ); 281 "X-Profession", "KADDRESSBOOK" );
282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
283 "X-AssistantsName", "KADDRESSBOOK" ); 283 "X-AssistantsName", "KADDRESSBOOK" );
284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
285 "X-ManagersName", "KADDRESSBOOK" ); 285 "X-ManagersName", "KADDRESSBOOK" );
286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
287 "X-SpousesName", "KADDRESSBOOK" ); 287 "X-SpousesName", "KADDRESSBOOK" );
288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
289 "X-Office", "KADDRESSBOOK" ); 289 "X-Office", "KADDRESSBOOK" );
290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
291 "X-IMAddress", "KADDRESSBOOK" ); 291 "X-IMAddress", "KADDRESSBOOK" );
292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
293 "X-Anniversary", "KADDRESSBOOK" ); 293 "X-Anniversary", "KADDRESSBOOK" );
294 294
295 //US added this field to become compatible with Opie/qtopia addressbook 295 //US added this field to become compatible with Opie/qtopia addressbook
296 // values can be "female" or "male" or "". An empty field represents undefined. 296 // values can be "female" or "male" or "". An empty field represents undefined.
297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
298 "X-Gender", "KADDRESSBOOK" ); 298 "X-Gender", "KADDRESSBOOK" );
299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
300 "X-Children", "KADDRESSBOOK" ); 300 "X-Children", "KADDRESSBOOK" );
301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
302 "X-FreeBusyUrl", "KADDRESSBOOK" ); 302 "X-FreeBusyUrl", "KADDRESSBOOK" );
303#endif 303#endif
304 initGUI(); 304 initGUI();
305 305
306 mIncSearchWidget->setFocus(); 306 mIncSearchWidget->setFocus();
307 307
308 308
309 connect( mViewManager, SIGNAL( selected( const QString& ) ), 309 connect( mViewManager, SIGNAL( selected( const QString& ) ),
310 SLOT( setContactSelected( const QString& ) ) ); 310 SLOT( setContactSelected( const QString& ) ) );
311 connect( mViewManager, SIGNAL( executed( const QString& ) ), 311 connect( mViewManager, SIGNAL( executed( const QString& ) ),
312 SLOT( executeContact( const QString& ) ) ); 312 SLOT( executeContact( const QString& ) ) );
313 313
314 connect( mViewManager, SIGNAL( deleteRequest( ) ), 314 connect( mViewManager, SIGNAL( deleteRequest( ) ),
315 SLOT( deleteContacts( ) ) ); 315 SLOT( deleteContacts( ) ) );
316 connect( mViewManager, SIGNAL( modified() ), 316 connect( mViewManager, SIGNAL( modified() ),
317 SLOT( setModified() ) ); 317 SLOT( setModified() ) );
318 318
319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
321 321
322 connect( mXXPortManager, SIGNAL( modified() ), 322 connect( mXXPortManager, SIGNAL( modified() ),
323 SLOT( setModified() ) ); 323 SLOT( setModified() ) );
324 324
325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
326 SLOT( incrementalSearch( const QString& ) ) ); 326 SLOT( incrementalSearch( const QString& ) ) );
327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
328 mJumpButtonBar, SLOT( recreateButtons() ) ); 328 mJumpButtonBar, SLOT( recreateButtons() ) );
329 329
330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
331 SLOT( sendMail( const QString& ) ) ); 331 SLOT( sendMail( const QString& ) ) );
332 332
333 333
334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
335 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 335 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
338 338
339 339
340#ifndef KAB_EMBEDDED 340#ifndef KAB_EMBEDDED
341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
342 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 342 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
343 343
344 connect( mDetails, SIGNAL( browse( const QString& ) ), 344 connect( mDetails, SIGNAL( browse( const QString& ) ),
345 SLOT( browse( const QString& ) ) ); 345 SLOT( browse( const QString& ) ) );
346 346
347 347
348 mAddressBookService = new KAddressBookService( this ); 348 mAddressBookService = new KAddressBookService( this );
349 349
350#endif //KAB_EMBEDDED 350#endif //KAB_EMBEDDED
351 351
352 mMessageTimer = new QTimer( this ); 352 mMessageTimer = new QTimer( this );
353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
354 mEditorDialog = 0; 354 mEditorDialog = 0;
355 createAddresseeEditorDialog( this ); 355 createAddresseeEditorDialog( this );
356 setModified( false ); 356 setModified( false );
357 mBRdisabled = false; 357 mBRdisabled = false;
358#ifndef DESKTOP_VERSION 358#ifndef DESKTOP_VERSION
359 infrared = 0; 359 infrared = 0;
360#endif 360#endif
361 //toggleBeamReceive( ); 361 //toggleBeamReceive( );
362 362
363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
364 QTimer::singleShot( 1000, this , SLOT ( updateToolBar())); 364 QTimer::singleShot( 10000, this , SLOT ( updateToolBar()));
365} 365}
366 366
367void KABCore::updateToolBar() 367void KABCore::updateToolBar()
368{ 368{
369 mMainWindow->toolBar()->repaint(); 369 mMainWindow->toolBar()->update();
370} 370}
371KABCore::~KABCore() 371KABCore::~KABCore()
372{ 372{
373 // save(); 373 // save();
374 //saveSettings(); 374 //saveSettings();
375 //KABPrefs::instance()->writeConfig(); 375 //KABPrefs::instance()->writeConfig();
376 delete AddresseeConfig::instance(); 376 delete AddresseeConfig::instance();
377 mAddressBook = 0; 377 mAddressBook = 0;
378 KABC::StdAddressBook::close(); 378 KABC::StdAddressBook::close();
379 379
380 delete syncManager; 380 delete syncManager;
381#ifndef DESKTOP_VERSION 381#ifndef DESKTOP_VERSION
382 if ( infrared ) 382 if ( infrared )
383 delete infrared; 383 delete infrared;
384#endif 384#endif
385} 385}
386void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 386void KABCore::receive( const QCString& cmsg, const QByteArray& data )
387{ 387{
388 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 388 qDebug("KA: QCOP message received: %s ", cmsg.data() );
389 if ( cmsg == "setDocument(QString)" ) { 389 if ( cmsg == "setDocument(QString)" ) {
390 QDataStream stream( data, IO_ReadOnly ); 390 QDataStream stream( data, IO_ReadOnly );
391 QString fileName; 391 QString fileName;
392 stream >> fileName; 392 stream >> fileName;
393 recieve( fileName ); 393 recieve( fileName );
394 return; 394 return;
395 } 395 }
396} 396}
397void KABCore::toggleBeamReceive( ) 397void KABCore::toggleBeamReceive( )
398{ 398{
399 if ( mBRdisabled ) 399 if ( mBRdisabled )
400 return; 400 return;
401#ifndef DESKTOP_VERSION 401#ifndef DESKTOP_VERSION
402 if ( infrared ) { 402 if ( infrared ) {
403 qDebug("AB disable BeamReceive "); 403 qDebug("AB disable BeamReceive ");
404 delete infrared; 404 delete infrared;
405 infrared = 0; 405 infrared = 0;
406 mActionBR->setChecked(false); 406 mActionBR->setChecked(false);
407 return; 407 return;
408 } 408 }
409 qDebug("AB enable BeamReceive "); 409 qDebug("AB enable BeamReceive ");
410 mActionBR->setChecked(true); 410 mActionBR->setChecked(true);
411 411
412 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 412 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
413 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 413 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
414#endif 414#endif
415} 415}
416 416
417 417
418void KABCore::disableBR(bool b) 418void KABCore::disableBR(bool b)
419{ 419{
420#ifndef DESKTOP_VERSION 420#ifndef DESKTOP_VERSION
421 if ( b ) { 421 if ( b ) {
422 if ( infrared ) { 422 if ( infrared ) {
423 toggleBeamReceive( ); 423 toggleBeamReceive( );
424 } 424 }
425 mBRdisabled = true; 425 mBRdisabled = true;
426 } else { 426 } else {
427 if ( mBRdisabled ) { 427 if ( mBRdisabled ) {
428 mBRdisabled = false; 428 mBRdisabled = false;
429 //toggleBeamReceive( ); 429 //toggleBeamReceive( );
430 } 430 }
431 } 431 }
432#endif 432#endif
433 433
434} 434}
435void KABCore::recieve( QString fn ) 435void KABCore::recieve( QString fn )
436{ 436{
437 //qDebug("KABCore::recieve "); 437 //qDebug("KABCore::recieve ");
438 int count = mAddressBook->importFromFile( fn, true ); 438 int count = mAddressBook->importFromFile( fn, true );
439 if ( count ) 439 if ( count )
440 setModified( true ); 440 setModified( true );
441 mViewManager->refreshView(); 441 mViewManager->refreshView();
442 message(i18n("%1 contact(s) received!").arg( count )); 442 message(i18n("%1 contact(s) received!").arg( count ));
443 topLevelWidget()->showMaximized(); 443 topLevelWidget()->showMaximized();
444 topLevelWidget()->raise(); 444 topLevelWidget()->raise();
445} 445}
446void KABCore::restoreSettings() 446void KABCore::restoreSettings()
447{ 447{
448 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 448 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
449 449
450 bool state; 450 bool state;
451 451
452 if (mMultipleViewsAtOnce) 452 if (mMultipleViewsAtOnce)
453 state = KABPrefs::instance()->mDetailsPageVisible; 453 state = KABPrefs::instance()->mDetailsPageVisible;
454 else 454 else
455 state = false; 455 state = false;
456 456
457 mActionDetails->setChecked( state ); 457 mActionDetails->setChecked( state );
458 setDetailsVisible( state ); 458 setDetailsVisible( state );
459 459
460 state = KABPrefs::instance()->mJumpButtonBarVisible; 460 state = KABPrefs::instance()->mJumpButtonBarVisible;
461 461
462 mActionJumpBar->setChecked( state ); 462 mActionJumpBar->setChecked( state );
463 setJumpButtonBarVisible( state ); 463 setJumpButtonBarVisible( state );
464/*US 464/*US
465 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 465 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
466 if ( splitterSize.count() == 0 ) { 466 if ( splitterSize.count() == 0 ) {
467 splitterSize.append( width() / 2 ); 467 splitterSize.append( width() / 2 );
468 splitterSize.append( width() / 2 ); 468 splitterSize.append( width() / 2 );
469 } 469 }
470 mMiniSplitter->setSizes( splitterSize ); 470 mMiniSplitter->setSizes( splitterSize );
471 if ( mExtensionBarSplitter ) { 471 if ( mExtensionBarSplitter ) {
472 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 472 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
473 if ( splitterSize.count() == 0 ) { 473 if ( splitterSize.count() == 0 ) {
474 splitterSize.append( width() / 2 ); 474 splitterSize.append( width() / 2 );
475 splitterSize.append( width() / 2 ); 475 splitterSize.append( width() / 2 );
476 } 476 }
477 mExtensionBarSplitter->setSizes( splitterSize ); 477 mExtensionBarSplitter->setSizes( splitterSize );
478 478
479 } 479 }
480*/ 480*/
481 mViewManager->restoreSettings(); 481 mViewManager->restoreSettings();
482 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 482 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
483 mExtensionManager->restoreSettings(); 483 mExtensionManager->restoreSettings();
484#ifdef DESKTOP_VERSION 484#ifdef DESKTOP_VERSION
485 int wid = width(); 485 int wid = width();
486 if ( wid < 10 ) 486 if ( wid < 10 )
487 wid = 400; 487 wid = 400;
488#else 488#else
489 int wid = QApplication::desktop()->width(); 489 int wid = QApplication::desktop()->width();
490 if ( wid < 640 ) 490 if ( wid < 640 )
491 wid = QApplication::desktop()->height(); 491 wid = QApplication::desktop()->height();
492#endif 492#endif
493 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 493 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
494 if ( true /*splitterSize.count() == 0*/ ) { 494 if ( true /*splitterSize.count() == 0*/ ) {
495 splitterSize.append( wid / 2 ); 495 splitterSize.append( wid / 2 );
496 splitterSize.append( wid / 2 ); 496 splitterSize.append( wid / 2 );
497 } 497 }
498 mMiniSplitter->setSizes( splitterSize ); 498 mMiniSplitter->setSizes( splitterSize );
499 if ( mExtensionBarSplitter ) { 499 if ( mExtensionBarSplitter ) {
500 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 500 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
501 if ( true /*splitterSize.count() == 0*/ ) { 501 if ( true /*splitterSize.count() == 0*/ ) {
502 splitterSize.append( wid / 2 ); 502 splitterSize.append( wid / 2 );
503 splitterSize.append( wid / 2 ); 503 splitterSize.append( wid / 2 );
504 } 504 }
505 mExtensionBarSplitter->setSizes( splitterSize ); 505 mExtensionBarSplitter->setSizes( splitterSize );
506 506
507 } 507 }
508 508
509 509
510} 510}
511 511
512void KABCore::saveSettings() 512void KABCore::saveSettings()
513{ 513{
514 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 514 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
515 if ( mExtensionBarSplitter ) 515 if ( mExtensionBarSplitter )
516 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 516 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
517 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 517 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
518 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 518 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
519#ifndef KAB_EMBEDDED 519#ifndef KAB_EMBEDDED
520 520
521 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 521 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
522 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 522 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
523#endif //KAB_EMBEDDED 523#endif //KAB_EMBEDDED
524 mExtensionManager->saveSettings(); 524 mExtensionManager->saveSettings();
525 mViewManager->saveSettings(); 525 mViewManager->saveSettings();
526 526
527 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 527 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
528} 528}
529 529
530KABC::AddressBook *KABCore::addressBook() const 530KABC::AddressBook *KABCore::addressBook() const
531{ 531{
532 return mAddressBook; 532 return mAddressBook;
533} 533}
534 534
535KConfig *KABCore::config() 535KConfig *KABCore::config()
536{ 536{
537#ifndef KAB_EMBEDDED 537#ifndef KAB_EMBEDDED
538 return KABPrefs::instance()->config(); 538 return KABPrefs::instance()->config();
539#else //KAB_EMBEDDED 539#else //KAB_EMBEDDED
540 return KABPrefs::instance()->getConfig(); 540 return KABPrefs::instance()->getConfig();
541#endif //KAB_EMBEDDED 541#endif //KAB_EMBEDDED
542} 542}
543 543
544KActionCollection *KABCore::actionCollection() const 544KActionCollection *KABCore::actionCollection() const
545{ 545{
546 return mGUIClient->actionCollection(); 546 return mGUIClient->actionCollection();
547} 547}
548 548
549KABC::Field *KABCore::currentSearchField() const 549KABC::Field *KABCore::currentSearchField() const
550{ 550{
551 if (mIncSearchWidget) 551 if (mIncSearchWidget)
552 return mIncSearchWidget->currentField(); 552 return mIncSearchWidget->currentField();
553 else 553 else
554 return 0; 554 return 0;
555} 555}
556 556
557QStringList KABCore::selectedUIDs() const 557QStringList KABCore::selectedUIDs() const
558{ 558{
559 return mViewManager->selectedUids(); 559 return mViewManager->selectedUids();
560} 560}
561 561
562KABC::Resource *KABCore::requestResource( QWidget *parent ) 562KABC::Resource *KABCore::requestResource( QWidget *parent )
563{ 563{
564 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 564 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
565 565
566 QPtrList<KRES::Resource> kresResources; 566 QPtrList<KRES::Resource> kresResources;
567 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 567 QPtrListIterator<KABC::Resource> resIt( kabcResources );
568 KABC::Resource *resource; 568 KABC::Resource *resource;
569 while ( ( resource = resIt.current() ) != 0 ) { 569 while ( ( resource = resIt.current() ) != 0 ) {
570 ++resIt; 570 ++resIt;
571 if ( !resource->readOnly() ) { 571 if ( !resource->readOnly() ) {
572 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 572 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
573 if ( res ) 573 if ( res )
574 kresResources.append( res ); 574 kresResources.append( res );
575 } 575 }
576 } 576 }
577 577
578 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 578 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
579 return static_cast<KABC::Resource*>( res ); 579 return static_cast<KABC::Resource*>( res );
580} 580}
581 581
582#ifndef KAB_EMBEDDED 582#ifndef KAB_EMBEDDED
583KAboutData *KABCore::createAboutData() 583KAboutData *KABCore::createAboutData()
584#else //KAB_EMBEDDED 584#else //KAB_EMBEDDED
585void KABCore::createAboutData() 585void KABCore::createAboutData()
586#endif //KAB_EMBEDDED 586#endif //KAB_EMBEDDED
587{ 587{
588#ifndef KAB_EMBEDDED 588#ifndef KAB_EMBEDDED
589 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 589 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
590 "3.1", I18N_NOOP( "The KDE Address Book" ), 590 "3.1", I18N_NOOP( "The KDE Address Book" ),
591 KAboutData::License_GPL_V2, 591 KAboutData::License_GPL_V2,
592 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 592 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
593 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 593 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
594 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 594 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
595 about->addAuthor( "Cornelius Schumacher", 595 about->addAuthor( "Cornelius Schumacher",
596 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 596 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
597 "schumacher@kde.org" ); 597 "schumacher@kde.org" );
598 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 598 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
599 "mpilone@slac.com" ); 599 "mpilone@slac.com" );
600 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 600 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
601 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 601 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
602 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 602 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
603 "michel@klaralvdalens-datakonsult.se" ); 603 "michel@klaralvdalens-datakonsult.se" );
604 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 604 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
605 "hansen@kde.org" ); 605 "hansen@kde.org" );
606 606
607 return about; 607 return about;
608#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
609 609
610 QString version; 610 QString version;
611#include <../version> 611#include <../version>
612 QMessageBox::about( this, "About KAddressbook/Pi", 612 QMessageBox::about( this, "About KAddressbook/Pi",
613 "KAddressbook/Platform-independent\n" 613 "KAddressbook/Platform-independent\n"
614 "(KA/Pi) " +version + " - " + 614 "(KA/Pi) " +version + " - " +
615#ifdef DESKTOP_VERSION 615#ifdef DESKTOP_VERSION
616 "Desktop Edition\n" 616 "Desktop Edition\n"
617#else 617#else
618 "PDA-Edition\n" 618 "PDA-Edition\n"
619 "for: Zaurus 5500 / 7x0 / 8x0\n" 619 "for: Zaurus 5500 / 7x0 / 8x0\n"
620#endif 620#endif
621 621
622 "(c) 2004 Ulf Schenk\n" 622 "(c) 2004 Ulf Schenk\n"
623 "(c) 2004 Lutz Rogowski\n" 623 "(c) 2004 Lutz Rogowski\n"
624 "(c) 1997-2003, The KDE PIM Team\n" 624 "(c) 1997-2003, The KDE PIM Team\n"
625 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 625 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
626 "Don Sanders Original author\n" 626 "Don Sanders Original author\n"
627 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 627 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
628 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 628 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
629 "Greg Stern DCOP interface\n" 629 "Greg Stern DCOP interface\n"
630 "Mark Westcot Contact pinning\n" 630 "Mark Westcot Contact pinning\n"
631 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 631 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
632 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 632 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
633#ifdef _WIN32_ 633#ifdef _WIN32_
634 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 634 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
635#endif 635#endif
636 ); 636 );
637} 637}
638 638
639void KABCore::setContactSelected( const QString &uid ) 639void KABCore::setContactSelected( const QString &uid )
640{ 640{
641 KABC::Addressee addr = mAddressBook->findByUid( uid ); 641 KABC::Addressee addr = mAddressBook->findByUid( uid );
642 if ( !mDetails->isHidden() ) 642 if ( !mDetails->isHidden() )
643 mDetails->setAddressee( addr ); 643 mDetails->setAddressee( addr );
644 644
645 if ( !addr.isEmpty() ) { 645 if ( !addr.isEmpty() ) {
646 emit contactSelected( addr.formattedName() ); 646 emit contactSelected( addr.formattedName() );
647 KABC::Picture pic = addr.photo(); 647 KABC::Picture pic = addr.photo();
648 if ( pic.isIntern() ) { 648 if ( pic.isIntern() ) {
649//US emit contactSelected( pic.data() ); 649//US emit contactSelected( pic.data() );
650//US instead use: 650//US instead use:
651 QPixmap px; 651 QPixmap px;
652 if (pic.data().isNull() != true) 652 if (pic.data().isNull() != true)
653 { 653 {
654 px.convertFromImage(pic.data()); 654 px.convertFromImage(pic.data());
655 } 655 }
656 656
657 emit contactSelected( px ); 657 emit contactSelected( px );
658 } 658 }
659 } 659 }
660 660
661 661
662 mExtensionManager->setSelectionChanged(); 662 mExtensionManager->setSelectionChanged();
663 663
664 // update the actions 664 // update the actions
665 bool selected = !uid.isEmpty(); 665 bool selected = !uid.isEmpty();
666 666
667 if ( mReadWrite ) { 667 if ( mReadWrite ) {
668 mActionCut->setEnabled( selected ); 668 mActionCut->setEnabled( selected );
669 mActionPaste->setEnabled( selected ); 669 mActionPaste->setEnabled( selected );
670 } 670 }
671 671
672 mActionCopy->setEnabled( selected ); 672 mActionCopy->setEnabled( selected );
673 mActionDelete->setEnabled( selected ); 673 mActionDelete->setEnabled( selected );
674 mActionEditAddressee->setEnabled( selected ); 674 mActionEditAddressee->setEnabled( selected );
675 mActionMail->setEnabled( selected ); 675 mActionMail->setEnabled( selected );
676 mActionMailVCard->setEnabled( selected ); 676 mActionMailVCard->setEnabled( selected );
677 //if (mActionBeam) 677 //if (mActionBeam)
678 //mActionBeam->setEnabled( selected ); 678 //mActionBeam->setEnabled( selected );
679 679
680 if (mActionBeamVCard) 680 if (mActionBeamVCard)
681 mActionBeamVCard->setEnabled( selected ); 681 mActionBeamVCard->setEnabled( selected );
682 682
683 mActionWhoAmI->setEnabled( selected ); 683 mActionWhoAmI->setEnabled( selected );
684} 684}
685 685
686void KABCore::sendMail() 686void KABCore::sendMail()
687{ 687{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 688 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 689}
690 690
691void KABCore::sendMail( const QString& emaillist ) 691void KABCore::sendMail( const QString& emaillist )
692{ 692{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 694 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 696 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 697 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 698}
699 699
700 700
701 701
702void KABCore::mailVCard() 702void KABCore::mailVCard()
703{ 703{
704 QStringList uids = mViewManager->selectedUids(); 704 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 705 if ( !uids.isEmpty() )
706 mailVCard( uids ); 706 mailVCard( uids );
707} 707}
708 708
709void KABCore::mailVCard( const QStringList& uids ) 709void KABCore::mailVCard( const QStringList& uids )
710{ 710{
711 QStringList urls; 711 QStringList urls;
712 712
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 714
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 715 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 716
717 717
718 718
719 QDir().mkdir( dirName, true ); 719 QDir().mkdir( dirName, true );
720 720
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 722 KABC::Addressee a = mAddressBook->findByUid( *it );
723 723
724 if ( a.isEmpty() ) 724 if ( a.isEmpty() )
725 continue; 725 continue;
726 726
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 727 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 728
729 QString fileName = dirName + "/" + name; 729 QString fileName = dirName + "/" + name;
730 730
731 QFile outFile(fileName); 731 QFile outFile(fileName);
732 732
733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
734 KABC::VCardConverter converter; 734 KABC::VCardConverter converter;
735 QString vcard; 735 QString vcard;
736 736
737 converter.addresseeToVCard( a, vcard ); 737 converter.addresseeToVCard( a, vcard );
738 738
739 QTextStream t( &outFile ); // use a text stream 739 QTextStream t( &outFile ); // use a text stream
740 t.setEncoding( QTextStream::UnicodeUTF8 ); 740 t.setEncoding( QTextStream::UnicodeUTF8 );
741 t << vcard; 741 t << vcard;
742 742
743 outFile.close(); 743 outFile.close();
744 744
745 urls.append( fileName ); 745 urls.append( fileName );
746 } 746 }
747 } 747 }
748 748
749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
750 750
751 751
752/*US 752/*US
753 kapp->invokeMailer( QString::null, QString::null, QString::null, 753 kapp->invokeMailer( QString::null, QString::null, QString::null,
754 QString::null, // subject 754 QString::null, // subject
755 QString::null, // body 755 QString::null, // body
756 QString::null, 756 QString::null,
757 urls ); // attachments 757 urls ); // attachments
758*/ 758*/
759 759
760} 760}
761 761
762/** 762/**
763 Beams the "WhoAmI contact. 763 Beams the "WhoAmI contact.
764*/ 764*/
765void KABCore::beamMySelf() 765void KABCore::beamMySelf()
766{ 766{
767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
768 if (!a.isEmpty()) 768 if (!a.isEmpty())
769 { 769 {
770 QStringList uids; 770 QStringList uids;
771 uids << a.uid(); 771 uids << a.uid();
772 772
773 beamVCard(uids); 773 beamVCard(uids);
774 } else { 774 } else {
775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
776 776
777 777
778 } 778 }
779} 779}
780void KABCore::updateMainWindow()
781{
782
783 mMainWindow->showMaximized();
784 mMainWindow->update();
785}
780void KABCore::resizeEvent(QResizeEvent* e ) 786void KABCore::resizeEvent(QResizeEvent* e )
781{ 787{
782 if ( !mMiniSplitter ) 788 if ( !mMiniSplitter )
783 return; 789 return;
784 if ( QApplication::desktop()->width() >= 480 ) { 790 if ( QApplication::desktop()->width() >= 480 ) {
785 int fac = QApplication::desktop()->width()/QApplication::desktop()->height(); 791 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
786 if ( fac > 0 ) { // e.g. 640x480
787 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 792 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
788 mMiniSplitter->setOrientation( Qt::Horizontal); 793 mMiniSplitter->setOrientation( Qt::Horizontal);
789 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 794 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
790 if ( QApplication::desktop()->width() <= 640 ) 795 if ( QApplication::desktop()->width() <= 640 ) {
791 topLevelWidget()->showMaximized(); 796 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
797 mViewManager->getFilterAction()->setComboWidth( 150 );
798 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
799 }
792 } 800 }
793 } else {// e.g. 480x640 801 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
794 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 802 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
795 mMiniSplitter->setOrientation( Qt::Vertical ); 803 mMiniSplitter->setOrientation( Qt::Vertical );
796 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 804 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
797 if ( QApplication::desktop()->width() <= 640 ) 805 if ( QApplication::desktop()->width() <= 640 ) {
798 topLevelWidget()->showMaximized(); 806 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
807 mMainWindow->showMinimized();
808 mViewManager->getFilterAction()->setComboWidth( 0 );
809 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
810 }
799 } 811 }
800 } 812 }
801 } 813 }
802 814
803} 815}
804void KABCore::export2phone() 816void KABCore::export2phone()
805{ 817{
806 818
807 QStringList uids; 819 QStringList uids;
808 XXPortSelectDialog dlg( this, false, this ); 820 XXPortSelectDialog dlg( this, false, this );
809 if ( dlg.exec() ) 821 if ( dlg.exec() )
810 uids = dlg.uids(); 822 uids = dlg.uids();
811 else 823 else
812 return; 824 return;
813 if ( uids.isEmpty() ) 825 if ( uids.isEmpty() )
814 return; 826 return;
815 // qDebug("count %d ", uids.count()); 827 // qDebug("count %d ", uids.count());
816 828
817 KAex2phonePrefs ex2phone; 829 KAex2phonePrefs ex2phone;
818 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 830 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
819 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 831 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
820 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 832 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
821 833
822 if ( !ex2phone.exec() ) { 834 if ( !ex2phone.exec() ) {
823 return; 835 return;
824 } 836 }
825 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 837 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
826 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 838 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
827 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 839 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
828 840
829 841
830 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 842 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
831 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 843 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
832 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 844 KPimGlobalPrefs::instance()->mEx2PhoneModel );
833 845
834 QString fileName = getPhoneFile(); 846 QString fileName = getPhoneFile();
835 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 847 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
836 return; 848 return;
837 849
838 message(i18n("Exporting to phone...")); 850 message(i18n("Exporting to phone..."));
839 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 851 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
840 852
841} 853}
842QString KABCore::getPhoneFile() 854QString KABCore::getPhoneFile()
843{ 855{
844#ifdef DESKTOP_VERSION 856#ifdef DESKTOP_VERSION
845 return locateLocal("tmp", "phonefile.vcf"); 857 return locateLocal("tmp", "phonefile.vcf");
846#else 858#else
847 return "/tmp/phonefile.vcf"; 859 return "/tmp/phonefile.vcf";
848#endif 860#endif
849 861
850} 862}
851void KABCore::writeToPhone( ) 863void KABCore::writeToPhone( )
852{ 864{
853 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 865 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
854 message(i18n("Export to phone finished!")); 866 message(i18n("Export to phone finished!"));
855 else 867 else
856 qDebug(i18n("Error exporting to phone")); 868 qDebug(i18n("Error exporting to phone"));
857} 869}
858void KABCore::beamVCard() 870void KABCore::beamVCard()
859{ 871{
860 QStringList uids = mViewManager->selectedUids(); 872 QStringList uids = mViewManager->selectedUids();
861 if ( !uids.isEmpty() ) 873 if ( !uids.isEmpty() )
862 beamVCard( uids ); 874 beamVCard( uids );
863} 875}
864 876
865 877
866void KABCore::beamVCard(const QStringList& uids) 878void KABCore::beamVCard(const QStringList& uids)
867{ 879{
868 880
869 // LR: we should use the /tmp dir on the Zaurus, 881 // LR: we should use the /tmp dir on the Zaurus,
870 // because: /tmp = RAM, (HOME)/kdepim = flash memory 882 // because: /tmp = RAM, (HOME)/kdepim = flash memory
871 883
872#ifdef DESKTOP_VERSION 884#ifdef DESKTOP_VERSION
873 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 885 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
874#else 886#else
875 QString fileName = "/tmp/kapibeamfile.vcf"; 887 QString fileName = "/tmp/kapibeamfile.vcf";
876#endif 888#endif
877 889
878 KABC::VCardConverter converter; 890 KABC::VCardConverter converter;
879 QString description; 891 QString description;
880 QString datastream; 892 QString datastream;
881 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 893 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
882 KABC::Addressee a = mAddressBook->findByUid( *it ); 894 KABC::Addressee a = mAddressBook->findByUid( *it );
883 895
884 if ( a.isEmpty() ) 896 if ( a.isEmpty() )
885 continue; 897 continue;
886 898
887 if (description.isEmpty()) 899 if (description.isEmpty())
888 description = a.formattedName(); 900 description = a.formattedName();
889 901
890 QString vcard; 902 QString vcard;
891 converter.addresseeToVCard( a, vcard ); 903 converter.addresseeToVCard( a, vcard );
892 int start = 0; 904 int start = 0;
893 int next; 905 int next;
894 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 906 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
895 int semi = vcard.find(";", next); 907 int semi = vcard.find(";", next);
896 int dopp = vcard.find(":", next); 908 int dopp = vcard.find(":", next);
897 int sep; 909 int sep;
898 if ( semi < dopp && semi >= 0 ) 910 if ( semi < dopp && semi >= 0 )
899 sep = semi ; 911 sep = semi ;
900 else 912 else
901 sep = dopp; 913 sep = dopp;
902 datastream +=vcard.mid( start, next - start); 914 datastream +=vcard.mid( start, next - start);
903 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 915 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
904 start = sep; 916 start = sep;
905 } 917 }
906 datastream += vcard.mid( start,vcard.length() ); 918 datastream += vcard.mid( start,vcard.length() );
907 } 919 }
908#ifndef DESKTOP_VERSION 920#ifndef DESKTOP_VERSION
909 QFile outFile(fileName); 921 QFile outFile(fileName);
910 if ( outFile.open(IO_WriteOnly) ) { 922 if ( outFile.open(IO_WriteOnly) ) {
911 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 923 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
912 QTextStream t( &outFile ); // use a text stream 924 QTextStream t( &outFile ); // use a text stream
913 //t.setEncoding( QTextStream::UnicodeUTF8 ); 925 //t.setEncoding( QTextStream::UnicodeUTF8 );
914 t.setEncoding( QTextStream::Latin1 ); 926 t.setEncoding( QTextStream::Latin1 );
915 t <<datastream.latin1(); 927 t <<datastream.latin1();
916 outFile.close(); 928 outFile.close();
917 Ir *ir = new Ir( this ); 929 Ir *ir = new Ir( this );
918 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 930 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
919 ir->send( fileName, description, "text/x-vCard" ); 931 ir->send( fileName, description, "text/x-vCard" );
920 } else { 932 } else {
921 qDebug("Error open temp beam file "); 933 qDebug("Error open temp beam file ");
922 return; 934 return;
923 } 935 }
924#endif 936#endif
925 937
926} 938}
927 939
928void KABCore::beamDone( Ir *ir ) 940void KABCore::beamDone( Ir *ir )
929{ 941{
930#ifndef DESKTOP_VERSION 942#ifndef DESKTOP_VERSION
931 delete ir; 943 delete ir;
932#endif 944#endif
933 topLevelWidget()->raise(); 945 topLevelWidget()->raise();
934 message( i18n("Beaming finished!") ); 946 message( i18n("Beaming finished!") );
935} 947}
936 948
937 949
938void KABCore::browse( const QString& url ) 950void KABCore::browse( const QString& url )
939{ 951{
940#ifndef KAB_EMBEDDED 952#ifndef KAB_EMBEDDED
941 kapp->invokeBrowser( url ); 953 kapp->invokeBrowser( url );
942#else //KAB_EMBEDDED 954#else //KAB_EMBEDDED
943 qDebug("KABCore::browse must be fixed"); 955 qDebug("KABCore::browse must be fixed");
944#endif //KAB_EMBEDDED 956#endif //KAB_EMBEDDED
945} 957}
946 958
947void KABCore::selectAllContacts() 959void KABCore::selectAllContacts()
948{ 960{
949 mViewManager->setSelected( QString::null, true ); 961 mViewManager->setSelected( QString::null, true );
950} 962}
951 963
952void KABCore::deleteContacts() 964void KABCore::deleteContacts()
953{ 965{
954 QStringList uidList = mViewManager->selectedUids(); 966 QStringList uidList = mViewManager->selectedUids();
955 deleteContacts( uidList ); 967 deleteContacts( uidList );
956} 968}
957 969
958void KABCore::deleteContacts( const QStringList &uids ) 970void KABCore::deleteContacts( const QStringList &uids )
959{ 971{
960 if ( uids.count() > 0 ) { 972 if ( uids.count() > 0 ) {
961 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 973 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
962 UndoStack::instance()->push( command ); 974 UndoStack::instance()->push( command );
963 RedoStack::instance()->clear(); 975 RedoStack::instance()->clear();
964 976
965 // now if we deleted anything, refresh 977 // now if we deleted anything, refresh
966 setContactSelected( QString::null ); 978 setContactSelected( QString::null );
967 setModified( true ); 979 setModified( true );
968 } 980 }
969} 981}
970 982
971void KABCore::copyContacts() 983void KABCore::copyContacts()
972{ 984{
973 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 985 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
974 986
975 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 987 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
976 988
977 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 989 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
978 990
979 QClipboard *cb = QApplication::clipboard(); 991 QClipboard *cb = QApplication::clipboard();
980 cb->setText( clipText ); 992 cb->setText( clipText );
981} 993}
982 994
983void KABCore::cutContacts() 995void KABCore::cutContacts()
984{ 996{
985 QStringList uidList = mViewManager->selectedUids(); 997 QStringList uidList = mViewManager->selectedUids();
986 998
987//US if ( uidList.size() > 0 ) { 999//US if ( uidList.size() > 0 ) {
988 if ( uidList.count() > 0 ) { 1000 if ( uidList.count() > 0 ) {
989 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1001 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
990 UndoStack::instance()->push( command ); 1002 UndoStack::instance()->push( command );
991 RedoStack::instance()->clear(); 1003 RedoStack::instance()->clear();
992 1004
993 setModified( true ); 1005 setModified( true );
994 } 1006 }
995} 1007}
996 1008
997void KABCore::pasteContacts() 1009void KABCore::pasteContacts()
998{ 1010{
999 QClipboard *cb = QApplication::clipboard(); 1011 QClipboard *cb = QApplication::clipboard();
1000 1012
1001 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1013 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1002 1014
1003 pasteContacts( list ); 1015 pasteContacts( list );
1004} 1016}
1005 1017
1006void KABCore::pasteContacts( KABC::Addressee::List &list ) 1018void KABCore::pasteContacts( KABC::Addressee::List &list )
1007{ 1019{
1008 KABC::Resource *resource = requestResource( this ); 1020 KABC::Resource *resource = requestResource( this );
1009 KABC::Addressee::List::Iterator it; 1021 KABC::Addressee::List::Iterator it;
1010 for ( it = list.begin(); it != list.end(); ++it ) 1022 for ( it = list.begin(); it != list.end(); ++it )
1011 (*it).setResource( resource ); 1023 (*it).setResource( resource );
1012 1024
1013 PwPasteCommand *command = new PwPasteCommand( this, list ); 1025 PwPasteCommand *command = new PwPasteCommand( this, list );
1014 UndoStack::instance()->push( command ); 1026 UndoStack::instance()->push( command );
1015 RedoStack::instance()->clear(); 1027 RedoStack::instance()->clear();
1016 1028
1017 setModified( true ); 1029 setModified( true );
1018} 1030}
1019 1031
1020void KABCore::setWhoAmI() 1032void KABCore::setWhoAmI()
1021{ 1033{
1022 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1034 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1023 1035
1024 if ( addrList.count() > 1 ) { 1036 if ( addrList.count() > 1 ) {
1025 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1037 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1026 return; 1038 return;
1027 } 1039 }
1028 1040
1029 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1041 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1030 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1042 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1031 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1043 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1032} 1044}
1033void KABCore::editCategories() 1045void KABCore::editCategories()
1034{ 1046{
1035 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1047 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1036 dlg.exec(); 1048 dlg.exec();
1037} 1049}
1038void KABCore::setCategories() 1050void KABCore::setCategories()
1039{ 1051{
1040 1052
1041 QStringList uids; 1053 QStringList uids;
1042 XXPortSelectDialog dlgx( this, false, this ); 1054 XXPortSelectDialog dlgx( this, false, this );
1043 if ( dlgx.exec() ) 1055 if ( dlgx.exec() )
1044 uids = dlgx.uids(); 1056 uids = dlgx.uids();
1045 else 1057 else
1046 return; 1058 return;
1047 if ( uids.isEmpty() ) 1059 if ( uids.isEmpty() )
1048 return; 1060 return;
1049 // qDebug("count %d ", uids.count()); 1061 // qDebug("count %d ", uids.count());
1050 1062
1051 1063
1052 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1064 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1053 if ( !dlg.exec() ) { 1065 if ( !dlg.exec() ) {
1054 message( i18n("Setting categories cancelled") ); 1066 message( i18n("Setting categories cancelled") );
1055 return; 1067 return;
1056 } 1068 }
1057 bool merge = false; 1069 bool merge = false;
1058 QString msg = i18n( "Merge with existing categories?" ); 1070 QString msg = i18n( "Merge with existing categories?" );
1059 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1071 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1060 merge = true; 1072 merge = true;
1061 1073
1062 message( i18n("Setting categories ... please wait!") ); 1074 message( i18n("Setting categories ... please wait!") );
1063 QStringList categories = dlg.selectedCategories(); 1075 QStringList categories = dlg.selectedCategories();
1064 1076
1065 //QStringList uids = mViewManager->selectedUids(); 1077 //QStringList uids = mViewManager->selectedUids();
1066 QStringList::Iterator it; 1078 QStringList::Iterator it;
1067 for ( it = uids.begin(); it != uids.end(); ++it ) { 1079 for ( it = uids.begin(); it != uids.end(); ++it ) {
1068 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1080 KABC::Addressee addr = mAddressBook->findByUid( *it );
1069 if ( !addr.isEmpty() ) { 1081 if ( !addr.isEmpty() ) {
1070 if ( !merge ) 1082 if ( !merge )
1071 addr.setCategories( categories ); 1083 addr.setCategories( categories );
1072 else { 1084 else {
1073 QStringList addrCategories = addr.categories(); 1085 QStringList addrCategories = addr.categories();
1074 QStringList::Iterator catIt; 1086 QStringList::Iterator catIt;
1075 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1087 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1076 if ( !addrCategories.contains( *catIt ) ) 1088 if ( !addrCategories.contains( *catIt ) )
1077 addrCategories.append( *catIt ); 1089 addrCategories.append( *catIt );
1078 } 1090 }
1079 addr.setCategories( addrCategories ); 1091 addr.setCategories( addrCategories );
1080 } 1092 }
1081 mAddressBook->insertAddressee( addr ); 1093 mAddressBook->insertAddressee( addr );
1082 } 1094 }
1083 } 1095 }
1084 1096
1085 if ( uids.count() > 0 ) 1097 if ( uids.count() > 0 )
1086 setModified( true ); 1098 setModified( true );
1087 message( i18n("Setting categories completed!") ); 1099 message( i18n("Setting categories completed!") );
1088} 1100}
1089 1101
1090void KABCore::setSearchFields( const KABC::Field::List &fields ) 1102void KABCore::setSearchFields( const KABC::Field::List &fields )
1091{ 1103{
1092 mIncSearchWidget->setFields( fields ); 1104 mIncSearchWidget->setFields( fields );
1093} 1105}
1094 1106
1095void KABCore::incrementalSearch( const QString& text ) 1107void KABCore::incrementalSearch( const QString& text )
1096{ 1108{
1097 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1109 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1098} 1110}
1099 1111
1100void KABCore::setModified() 1112void KABCore::setModified()
1101{ 1113{
1102 setModified( true ); 1114 setModified( true );
1103} 1115}
1104 1116
1105void KABCore::setModifiedWOrefresh() 1117void KABCore::setModifiedWOrefresh()
1106{ 1118{
1107 // qDebug("KABCore::setModifiedWOrefresh() "); 1119 // qDebug("KABCore::setModifiedWOrefresh() ");
1108 mModified = true; 1120 mModified = true;
1109 mActionSave->setEnabled( mModified ); 1121 mActionSave->setEnabled( mModified );
1110#ifdef DESKTOP_VERSION 1122#ifdef DESKTOP_VERSION
1111 mDetails->refreshView(); 1123 mDetails->refreshView();
1112#endif 1124#endif
1113 1125
1114} 1126}
1115void KABCore::setModified( bool modified ) 1127void KABCore::setModified( bool modified )
1116{ 1128{
1117 mModified = modified; 1129 mModified = modified;
1118 mActionSave->setEnabled( mModified ); 1130 mActionSave->setEnabled( mModified );
1119 1131
1120 if ( modified ) 1132 if ( modified )
1121 mJumpButtonBar->recreateButtons(); 1133 mJumpButtonBar->recreateButtons();
1122 1134
1123 mViewManager->refreshView(); 1135 mViewManager->refreshView();
1124 mDetails->refreshView(); 1136 mDetails->refreshView();
1125 1137
1126} 1138}
1127 1139
1128bool KABCore::modified() const 1140bool KABCore::modified() const
1129{ 1141{
1130 return mModified; 1142 return mModified;
1131} 1143}
1132 1144
1133void KABCore::contactModified( const KABC::Addressee &addr ) 1145void KABCore::contactModified( const KABC::Addressee &addr )
1134{ 1146{
1135 1147
1136 Command *command = 0; 1148 Command *command = 0;
1137 QString uid; 1149 QString uid;
1138 1150
1139 // check if it exists already 1151 // check if it exists already
1140 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1152 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1141 if ( origAddr.isEmpty() ) 1153 if ( origAddr.isEmpty() )
1142 command = new PwNewCommand( mAddressBook, addr ); 1154 command = new PwNewCommand( mAddressBook, addr );
1143 else { 1155 else {
1144 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1156 command = new PwEditCommand( mAddressBook, origAddr, addr );
1145 uid = addr.uid(); 1157 uid = addr.uid();
1146 } 1158 }
1147 1159
1148 UndoStack::instance()->push( command ); 1160 UndoStack::instance()->push( command );
1149 RedoStack::instance()->clear(); 1161 RedoStack::instance()->clear();
1150 1162
1151 setModified( true ); 1163 setModified( true );
1152} 1164}
1153 1165
1154void KABCore::newContact() 1166void KABCore::newContact()
1155{ 1167{
1156 1168
1157 1169
1158 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1170 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1159 1171
1160 QPtrList<KRES::Resource> kresResources; 1172 QPtrList<KRES::Resource> kresResources;
1161 QPtrListIterator<KABC::Resource> it( kabcResources ); 1173 QPtrListIterator<KABC::Resource> it( kabcResources );
1162 KABC::Resource *resource; 1174 KABC::Resource *resource;
1163 while ( ( resource = it.current() ) != 0 ) { 1175 while ( ( resource = it.current() ) != 0 ) {
1164 ++it; 1176 ++it;
1165 if ( !resource->readOnly() ) { 1177 if ( !resource->readOnly() ) {
1166 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1178 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1167 if ( res ) 1179 if ( res )
1168 kresResources.append( res ); 1180 kresResources.append( res );
1169 } 1181 }
1170 } 1182 }
1171 1183
1172 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1184 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1173 resource = static_cast<KABC::Resource*>( res ); 1185 resource = static_cast<KABC::Resource*>( res );
1174 1186
1175 if ( resource ) { 1187 if ( resource ) {
1176 KABC::Addressee addr; 1188 KABC::Addressee addr;
1177 addr.setResource( resource ); 1189 addr.setResource( resource );
1178 mEditorDialog->setAddressee( addr ); 1190 mEditorDialog->setAddressee( addr );
1179 KApplication::execDialog ( mEditorDialog ); 1191 KApplication::execDialog ( mEditorDialog );
1180 1192
1181 } else 1193 } else
1182 return; 1194 return;
1183 1195
1184 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1196 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1185 1197
1186 1198
1187} 1199}
1188 1200
1189void KABCore::addEmail( QString aStr ) 1201void KABCore::addEmail( QString aStr )
1190{ 1202{
1191#ifndef KAB_EMBEDDED 1203#ifndef KAB_EMBEDDED
1192 QString fullName, email; 1204 QString fullName, email;
1193 1205
1194 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1206 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1195 1207
1196 // Try to lookup the addressee matching the email address 1208 // Try to lookup the addressee matching the email address
1197 bool found = false; 1209 bool found = false;
1198 QStringList emailList; 1210 QStringList emailList;
1199 KABC::AddressBook::Iterator it; 1211 KABC::AddressBook::Iterator it;
1200 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1212 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1201 emailList = (*it).emails(); 1213 emailList = (*it).emails();
1202 if ( emailList.contains( email ) > 0 ) { 1214 if ( emailList.contains( email ) > 0 ) {
1203 found = true; 1215 found = true;
1204 (*it).setNameFromString( fullName ); 1216 (*it).setNameFromString( fullName );
1205 editContact( (*it).uid() ); 1217 editContact( (*it).uid() );
1206 } 1218 }
1207 } 1219 }
1208 1220
1209 if ( !found ) { 1221 if ( !found ) {
1210 KABC::Addressee addr; 1222 KABC::Addressee addr;
1211 addr.setNameFromString( fullName ); 1223 addr.setNameFromString( fullName );
1212 addr.insertEmail( email, true ); 1224 addr.insertEmail( email, true );
1213 1225
1214 mAddressBook->insertAddressee( addr ); 1226 mAddressBook->insertAddressee( addr );
1215 mViewManager->refreshView( addr.uid() ); 1227 mViewManager->refreshView( addr.uid() );
1216 editContact( addr.uid() ); 1228 editContact( addr.uid() );
1217 } 1229 }
1218#else //KAB_EMBEDDED 1230#else //KAB_EMBEDDED
1219 qDebug("KABCore::addEmail finsih method"); 1231 qDebug("KABCore::addEmail finsih method");
1220#endif //KAB_EMBEDDED 1232#endif //KAB_EMBEDDED
1221} 1233}
1222 1234
1223void KABCore::importVCard( const KURL &url, bool showPreview ) 1235void KABCore::importVCard( const KURL &url, bool showPreview )
1224{ 1236{
1225 mXXPortManager->importVCard( url, showPreview ); 1237 mXXPortManager->importVCard( url, showPreview );
1226} 1238}
1227void KABCore::importFromOL() 1239void KABCore::importFromOL()
1228{ 1240{
1229#ifdef _WIN32_ 1241#ifdef _WIN32_
1230 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1242 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1231 idgl->exec(); 1243 idgl->exec();
1232 KABC::Addressee::List list = idgl->getAddressList(); 1244 KABC::Addressee::List list = idgl->getAddressList();
1233 if ( list.count() > 0 ) { 1245 if ( list.count() > 0 ) {
1234 KABC::Addressee::List listNew; 1246 KABC::Addressee::List listNew;
1235 KABC::Addressee::List listExisting; 1247 KABC::Addressee::List listExisting;
1236 KABC::Addressee::List::Iterator it; 1248 KABC::Addressee::List::Iterator it;
1237 KABC::AddressBook::Iterator iter; 1249 KABC::AddressBook::Iterator iter;
1238 for ( it = list.begin(); it != list.end(); ++it ) { 1250 for ( it = list.begin(); it != list.end(); ++it ) {
1239 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1251 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1240 listNew.append( (*it) ); 1252 listNew.append( (*it) );
1241 else 1253 else
1242 listExisting.append( (*it) ); 1254 listExisting.append( (*it) );
1243 } 1255 }
1244 if ( listExisting.count() > 0 ) 1256 if ( listExisting.count() > 0 )
1245 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1257 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1246 if ( listNew.count() > 0 ) { 1258 if ( listNew.count() > 0 ) {
1247 pasteWithNewUid = false; 1259 pasteWithNewUid = false;
1248 pasteContacts( listNew ); 1260 pasteContacts( listNew );
1249 pasteWithNewUid = true; 1261 pasteWithNewUid = true;
1250 } 1262 }
1251 } 1263 }
1252 delete idgl; 1264 delete idgl;
1253#endif 1265#endif
1254} 1266}
1255 1267
1256void KABCore::importVCard( const QString &vCard, bool showPreview ) 1268void KABCore::importVCard( const QString &vCard, bool showPreview )
1257{ 1269{
1258 mXXPortManager->importVCard( vCard, showPreview ); 1270 mXXPortManager->importVCard( vCard, showPreview );
1259} 1271}
1260 1272
1261//US added a second method without defaultparameter 1273//US added a second method without defaultparameter
1262void KABCore::editContact2() { 1274void KABCore::editContact2() {
1263 editContact( QString::null ); 1275 editContact( QString::null );
1264} 1276}
1265 1277
1266void KABCore::editContact( const QString &uid ) 1278void KABCore::editContact( const QString &uid )
1267{ 1279{
1268 1280
1269 if ( mExtensionManager->isQuickEditVisible() ) 1281 if ( mExtensionManager->isQuickEditVisible() )
1270 return; 1282 return;
1271 1283
1272 // First, locate the contact entry 1284 // First, locate the contact entry
1273 QString localUID = uid; 1285 QString localUID = uid;
1274 if ( localUID.isNull() ) { 1286 if ( localUID.isNull() ) {
1275 QStringList uidList = mViewManager->selectedUids(); 1287 QStringList uidList = mViewManager->selectedUids();
1276 if ( uidList.count() > 0 ) 1288 if ( uidList.count() > 0 )
1277 localUID = *( uidList.at( 0 ) ); 1289 localUID = *( uidList.at( 0 ) );
1278 } 1290 }
1279 1291
1280 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1292 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1281 if ( !addr.isEmpty() ) { 1293 if ( !addr.isEmpty() ) {
1282 mEditorDialog->setAddressee( addr ); 1294 mEditorDialog->setAddressee( addr );
1283 KApplication::execDialog ( mEditorDialog ); 1295 KApplication::execDialog ( mEditorDialog );
1284 } 1296 }
1285} 1297}
1286 1298
1287/** 1299/**
1288 Shows or edits the detail view for the given uid. If the uid is QString::null, 1300 Shows or edits the detail view for the given uid. If the uid is QString::null,
1289 the method will try to find a selected addressee in the view. 1301 the method will try to find a selected addressee in the view.
1290 */ 1302 */
1291void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1303void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1292{ 1304{
1293 if ( mMultipleViewsAtOnce ) 1305 if ( mMultipleViewsAtOnce )
1294 { 1306 {
1295 editContact( uid ); 1307 editContact( uid );
1296 } 1308 }
1297 else 1309 else
1298 { 1310 {
1299 setDetailsVisible( true ); 1311 setDetailsVisible( true );
1300 mActionDetails->setChecked(true); 1312 mActionDetails->setChecked(true);
1301 } 1313 }
1302 1314
1303} 1315}
1304 1316
1305void KABCore::save() 1317void KABCore::save()
1306{ 1318{
1307 if (syncManager->blockSave()) 1319 if (syncManager->blockSave())
1308 return; 1320 return;
1309 if ( !mModified ) 1321 if ( !mModified )
1310 return; 1322 return;
1311 1323
1312 syncManager->setBlockSave(true); 1324 syncManager->setBlockSave(true);
1313 QString text = i18n( "There was an error while attempting to save\n the " 1325 QString text = i18n( "There was an error while attempting to save\n the "
1314 "address book. Please check that some \nother application is " 1326 "address book. Please check that some \nother application is "
1315 "not using it. " ); 1327 "not using it. " );
1316 message(i18n("Saving addressbook ... ")); 1328 message(i18n("Saving addressbook ... "));
1317#ifndef KAB_EMBEDDED 1329#ifndef KAB_EMBEDDED
1318 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1330 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1319 if ( !b || !b->save() ) { 1331 if ( !b || !b->save() ) {
1320 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1332 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1321 } 1333 }
1322#else //KAB_EMBEDDED 1334#else //KAB_EMBEDDED
1323 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1335 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1324 if ( !b || !b->save() ) { 1336 if ( !b || !b->save() ) {
1325 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1337 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1326 } 1338 }
1327#endif //KAB_EMBEDDED 1339#endif //KAB_EMBEDDED
1328 1340
1329 message(i18n("Addressbook saved!")); 1341 message(i18n("Addressbook saved!"));
1330 setModified( false ); 1342 setModified( false );
1331 syncManager->setBlockSave(false); 1343 syncManager->setBlockSave(false);
1332} 1344}
1333 1345
1334 1346
1335void KABCore::undo() 1347void KABCore::undo()
1336{ 1348{
1337 UndoStack::instance()->undo(); 1349 UndoStack::instance()->undo();
1338 1350
1339 // Refresh the view 1351 // Refresh the view
1340 mViewManager->refreshView(); 1352 mViewManager->refreshView();
1341} 1353}
1342 1354
1343void KABCore::redo() 1355void KABCore::redo()
1344{ 1356{
1345 RedoStack::instance()->redo(); 1357 RedoStack::instance()->redo();
1346 1358
1347 // Refresh the view 1359 // Refresh the view
1348 mViewManager->refreshView(); 1360 mViewManager->refreshView();
1349} 1361}
1350 1362
1351void KABCore::setJumpButtonBarVisible( bool visible ) 1363void KABCore::setJumpButtonBarVisible( bool visible )
1352{ 1364{
1353 if (mMultipleViewsAtOnce) 1365 if (mMultipleViewsAtOnce)
1354 { 1366 {
1355 if ( visible ) 1367 if ( visible )
1356 mJumpButtonBar->show(); 1368 mJumpButtonBar->show();
1357 else 1369 else
1358 mJumpButtonBar->hide(); 1370 mJumpButtonBar->hide();
1359 } 1371 }
1360 else 1372 else
1361 { 1373 {
1362 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1374 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1363 if (mViewManager->isVisible()) 1375 if (mViewManager->isVisible())
1364 { 1376 {
1365 if ( visible ) 1377 if ( visible )
1366 mJumpButtonBar->show(); 1378 mJumpButtonBar->show();
1367 else 1379 else
1368 mJumpButtonBar->hide(); 1380 mJumpButtonBar->hide();
1369 } 1381 }
1370 else 1382 else
1371 { 1383 {
1372 mJumpButtonBar->hide(); 1384 mJumpButtonBar->hide();
1373 } 1385 }
1374 } 1386 }
1375} 1387}
1376 1388
1377 1389
1378void KABCore::setDetailsToState() 1390void KABCore::setDetailsToState()
1379{ 1391{
1380 setDetailsVisible( mActionDetails->isChecked() ); 1392 setDetailsVisible( mActionDetails->isChecked() );
1381} 1393}
1382void KABCore::setDetailsToggle() 1394void KABCore::setDetailsToggle()
1383{ 1395{
1384 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1396 mActionDetails->setChecked( !mActionDetails->isChecked() );
1385 setDetailsToState(); 1397 setDetailsToState();
1386} 1398}
1387 1399
1388 1400
1389 1401
1390void KABCore::setDetailsVisible( bool visible ) 1402void KABCore::setDetailsVisible( bool visible )
1391{ 1403{
1392 if (visible && mDetails->isHidden()) 1404 if (visible && mDetails->isHidden())
1393 { 1405 {
1394 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1406 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1395 if ( addrList.count() > 0 ) 1407 if ( addrList.count() > 0 )
1396 mDetails->setAddressee( addrList[ 0 ] ); 1408 mDetails->setAddressee( addrList[ 0 ] );
1397 } 1409 }
1398 1410
1399 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1411 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1400 // the listview and the detailview. We do that by changing the splitbar size. 1412 // the listview and the detailview. We do that by changing the splitbar size.
1401 if (mMultipleViewsAtOnce) 1413 if (mMultipleViewsAtOnce)
1402 { 1414 {
1403 if ( visible ) 1415 if ( visible )
1404 mDetails->show(); 1416 mDetails->show();
1405 else 1417 else
1406 mDetails->hide(); 1418 mDetails->hide();
1407 } 1419 }
1408 else 1420 else
1409 { 1421 {
1410 if ( visible ) { 1422 if ( visible ) {
1411 mViewManager->hide(); 1423 mViewManager->hide();
1412 mDetails->show(); 1424 mDetails->show();
1413 mIncSearchWidget->setFocus(); 1425 mIncSearchWidget->setFocus();
1414 } 1426 }
1415 else { 1427 else {
1416 mViewManager->show(); 1428 mViewManager->show();
1417 mDetails->hide(); 1429 mDetails->hide();
1418 mViewManager->setFocusAV(); 1430 mViewManager->setFocusAV();
1419 } 1431 }
1420 setJumpButtonBarVisible( !visible ); 1432 setJumpButtonBarVisible( !visible );
1421 } 1433 }
1422 1434
1423} 1435}
1424 1436
1425void KABCore::extensionChanged( int id ) 1437void KABCore::extensionChanged( int id )
1426{ 1438{
1427 //change the details view only for non desktop systems 1439 //change the details view only for non desktop systems
1428#ifndef DESKTOP_VERSION 1440#ifndef DESKTOP_VERSION
1429 1441
1430 if (id == 0) 1442 if (id == 0)
1431 { 1443 {
1432 //the user disabled the extension. 1444 //the user disabled the extension.
1433 1445
1434 if (mMultipleViewsAtOnce) 1446 if (mMultipleViewsAtOnce)
1435 { // enable detailsview again 1447 { // enable detailsview again
1436 setDetailsVisible( true ); 1448 setDetailsVisible( true );
1437 mActionDetails->setChecked( true ); 1449 mActionDetails->setChecked( true );
1438 } 1450 }
1439 else 1451 else
1440 { //go back to the listview 1452 { //go back to the listview
1441 setDetailsVisible( false ); 1453 setDetailsVisible( false );
1442 mActionDetails->setChecked( false ); 1454 mActionDetails->setChecked( false );
1443 mActionDetails->setEnabled(true); 1455 mActionDetails->setEnabled(true);
1444 } 1456 }
1445 1457
1446 } 1458 }
1447 else 1459 else
1448 { 1460 {
1449 //the user enabled the extension. 1461 //the user enabled the extension.
1450 setDetailsVisible( false ); 1462 setDetailsVisible( false );
1451 mActionDetails->setChecked( false ); 1463 mActionDetails->setChecked( false );
1452 1464
1453 if (!mMultipleViewsAtOnce) 1465 if (!mMultipleViewsAtOnce)
1454 { 1466 {
1455 mActionDetails->setEnabled(false); 1467 mActionDetails->setEnabled(false);
1456 } 1468 }
1457 1469
1458 mExtensionManager->setSelectionChanged(); 1470 mExtensionManager->setSelectionChanged();
1459 1471
1460 } 1472 }
1461 1473
1462#endif// DESKTOP_VERSION 1474#endif// DESKTOP_VERSION
1463 1475
1464} 1476}
1465 1477
1466 1478
1467void KABCore::extensionModified( const KABC::Addressee::List &list ) 1479void KABCore::extensionModified( const KABC::Addressee::List &list )
1468{ 1480{
1469 1481
1470 if ( list.count() != 0 ) { 1482 if ( list.count() != 0 ) {
1471 KABC::Addressee::List::ConstIterator it; 1483 KABC::Addressee::List::ConstIterator it;
1472 for ( it = list.begin(); it != list.end(); ++it ) 1484 for ( it = list.begin(); it != list.end(); ++it )
1473 mAddressBook->insertAddressee( *it ); 1485 mAddressBook->insertAddressee( *it );
1474 if ( list.count() > 1 ) 1486 if ( list.count() > 1 )
1475 setModified(); 1487 setModified();
1476 else 1488 else
1477 setModifiedWOrefresh(); 1489 setModifiedWOrefresh();
1478 } 1490 }
1479 if ( list.count() == 0 ) 1491 if ( list.count() == 0 )
1480 mViewManager->refreshView(); 1492 mViewManager->refreshView();
1481 else 1493 else
1482 mViewManager->refreshView( list[ 0 ].uid() ); 1494 mViewManager->refreshView( list[ 0 ].uid() );
1483 1495
1484 1496
1485 1497
1486} 1498}
1487 1499
1488QString KABCore::getNameByPhone( const QString &phone ) 1500QString KABCore::getNameByPhone( const QString &phone )
1489{ 1501{
1490#ifndef KAB_EMBEDDED 1502#ifndef KAB_EMBEDDED
1491 QRegExp r( "[/*/-/ ]" ); 1503 QRegExp r( "[/*/-/ ]" );
1492 QString localPhone( phone ); 1504 QString localPhone( phone );
1493 1505
1494 bool found = false; 1506 bool found = false;
1495 QString ownerName = ""; 1507 QString ownerName = "";
1496 KABC::AddressBook::Iterator iter; 1508 KABC::AddressBook::Iterator iter;
1497 KABC::PhoneNumber::List::Iterator phoneIter; 1509 KABC::PhoneNumber::List::Iterator phoneIter;
1498 KABC::PhoneNumber::List phoneList; 1510 KABC::PhoneNumber::List phoneList;
1499 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1511 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1500 phoneList = (*iter).phoneNumbers(); 1512 phoneList = (*iter).phoneNumbers();
1501 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1513 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1502 ++phoneIter) { 1514 ++phoneIter) {
1503 // Get rid of separator chars so just the numbers are compared. 1515 // Get rid of separator chars so just the numbers are compared.
1504 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1516 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1505 ownerName = (*iter).formattedName(); 1517 ownerName = (*iter).formattedName();
1506 found = true; 1518 found = true;
1507 } 1519 }
1508 } 1520 }
1509 } 1521 }
1510 1522
1511 return ownerName; 1523 return ownerName;
1512#else //KAB_EMBEDDED 1524#else //KAB_EMBEDDED
1513 qDebug("KABCore::getNameByPhone finsih method"); 1525 qDebug("KABCore::getNameByPhone finsih method");
1514 return ""; 1526 return "";
1515#endif //KAB_EMBEDDED 1527#endif //KAB_EMBEDDED
1516 1528
1517} 1529}
1518 1530
1519void KABCore::openConfigDialog() 1531void KABCore::openConfigDialog()
1520{ 1532{
1521 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1533 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1522 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1534 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1523 ConfigureDialog->addModule(kabcfg ); 1535 ConfigureDialog->addModule(kabcfg );
1524 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1536 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1525 ConfigureDialog->addModule(kdelibcfg ); 1537 ConfigureDialog->addModule(kdelibcfg );
1526 1538
1527 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1539 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1528 this, SLOT( configurationChanged() ) ); 1540 this, SLOT( configurationChanged() ) );
1529 connect( ConfigureDialog, SIGNAL( okClicked() ), 1541 connect( ConfigureDialog, SIGNAL( okClicked() ),
1530 this, SLOT( configurationChanged() ) ); 1542 this, SLOT( configurationChanged() ) );
1531 saveSettings(); 1543 saveSettings();
1532#ifndef DESKTOP_VERSION 1544#ifndef DESKTOP_VERSION
1533 ConfigureDialog->showMaximized(); 1545 ConfigureDialog->showMaximized();
1534#endif 1546#endif
1535 if ( ConfigureDialog->exec() ) 1547 if ( ConfigureDialog->exec() )
1536 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1548 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1537 delete ConfigureDialog; 1549 delete ConfigureDialog;
1538} 1550}
1539 1551
1540void KABCore::openLDAPDialog() 1552void KABCore::openLDAPDialog()
1541{ 1553{
1542#ifndef KAB_EMBEDDED 1554#ifndef KAB_EMBEDDED
1543 if ( !mLdapSearchDialog ) { 1555 if ( !mLdapSearchDialog ) {
1544 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1556 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1545 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1557 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1546 SLOT( refreshView() ) ); 1558 SLOT( refreshView() ) );
1547 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1559 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1548 SLOT( setModified() ) ); 1560 SLOT( setModified() ) );
1549 } else 1561 } else
1550 mLdapSearchDialog->restoreSettings(); 1562 mLdapSearchDialog->restoreSettings();
1551 1563
1552 if ( mLdapSearchDialog->isOK() ) 1564 if ( mLdapSearchDialog->isOK() )
1553 mLdapSearchDialog->exec(); 1565 mLdapSearchDialog->exec();
1554#else //KAB_EMBEDDED 1566#else //KAB_EMBEDDED
1555 qDebug("KABCore::openLDAPDialog() finsih method"); 1567 qDebug("KABCore::openLDAPDialog() finsih method");
1556#endif //KAB_EMBEDDED 1568#endif //KAB_EMBEDDED
1557} 1569}
1558 1570
1559void KABCore::print() 1571void KABCore::print()
1560{ 1572{
1561#ifndef KAB_EMBEDDED 1573#ifndef KAB_EMBEDDED
1562 KPrinter printer; 1574 KPrinter printer;
1563 if ( !printer.setup( this ) ) 1575 if ( !printer.setup( this ) )
1564 return; 1576 return;
1565 1577
1566 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1578 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index fe2d3a2..88e83f0 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,514 +1,515 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 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 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 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 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. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <ksyncmanager.h> 36#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39#endif 39#endif
40 40
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class KABCore : public QWidget, public KSyncInterface
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 78
79 public: 79 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 81
82 82
83 ~KABCore(); 83 ~KABCore();
84 84
85 85
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 //US added functionality 87 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 88 QPopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 89 QPopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 90 QPopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 91 void addActionsManually();
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93 /** 93 /**
94 Restores the global settings. 94 Restores the global settings.
95 */ 95 */
96 void restoreSettings(); 96 void restoreSettings();
97 97
98 /** 98 /**
99 Saves the global settings. 99 Saves the global settings.
100 */ 100 */
101 void saveSettings(); 101 void saveSettings();
102 102
103 /** 103 /**
104 Returns a pointer to the StdAddressBook of the application. 104 Returns a pointer to the StdAddressBook of the application.
105 */ 105 */
106 KABC::AddressBook *addressBook() const; 106 KABC::AddressBook *addressBook() const;
107 107
108 /** 108 /**
109 Returns a pointer to the KConfig object of the application. 109 Returns a pointer to the KConfig object of the application.
110 */ 110 */
111 static KConfig *config(); 111 static KConfig *config();
112 112
113 /** 113 /**
114 Returns a pointer to the global KActionCollection object. So 114 Returns a pointer to the global KActionCollection object. So
115 other classes can register their actions easily. 115 other classes can register their actions easily.
116 */ 116 */
117 KActionCollection *actionCollection() const; 117 KActionCollection *actionCollection() const;
118 118
119 /** 119 /**
120 Returns the current search field of the Incremental Search Widget. 120 Returns the current search field of the Incremental Search Widget.
121 */ 121 */
122 KABC::Field *currentSearchField() const; 122 KABC::Field *currentSearchField() const;
123 123
124 /** 124 /**
125 Returns the uid list of the currently selected contacts. 125 Returns the uid list of the currently selected contacts.
126 */ 126 */
127 QStringList selectedUIDs() const; 127 QStringList selectedUIDs() const;
128 128
129 /** 129 /**
130 Displays the ResourceSelectDialog and returns the selected 130 Displays the ResourceSelectDialog and returns the selected
131 resource or a null pointer if no resource was selected by 131 resource or a null pointer if no resource was selected by
132 the user. 132 the user.
133 */ 133 */
134 KABC::Resource *requestResource( QWidget *parent ); 134 KABC::Resource *requestResource( QWidget *parent );
135 135
136#ifndef KAB_EMBEDDED 136#ifndef KAB_EMBEDDED
137 static KAboutData *createAboutData(); 137 static KAboutData *createAboutData();
138#endif //KAB_EMBEDDED 138#endif //KAB_EMBEDDED
139 139
140#ifdef KAB_EMBEDDED 140#ifdef KAB_EMBEDDED
141 inline QPopupMenu* getImportMenu() { return ImportMenu;} 141 inline QPopupMenu* getImportMenu() { return ImportMenu;}
142 inline QPopupMenu* getExportMenu() { return ExportMenu;} 142 inline QPopupMenu* getExportMenu() { return ExportMenu;}
143#endif //KAB_EMBEDDED 143#endif //KAB_EMBEDDED
144 144
145 public slots: 145 public slots:
146#ifdef KAB_EMBEDDED 146#ifdef KAB_EMBEDDED
147 void createAboutData(); 147 void createAboutData();
148#endif //KAB_EMBEDDED 148#endif //KAB_EMBEDDED
149 void setDetailsToggle(); 149 void setDetailsToggle();
150 150
151 void showLicence(); 151 void showLicence();
152 void faq(); 152 void faq();
153 void whatsnew() ; 153 void whatsnew() ;
154 void synchowto() ; 154 void synchowto() ;
155 void multisynchowto() ; 155 void multisynchowto() ;
156 void kdesynchowto() ; 156 void kdesynchowto() ;
157 void writeToPhone(); 157 void writeToPhone();
158 158
159 /** 159 /**
160 Is called whenever a contact is selected in the view. 160 Is called whenever a contact is selected in the view.
161 */ 161 */
162 void setContactSelected( const QString &uid ); 162 void setContactSelected( const QString &uid );
163 163
164 /** 164 /**
165 Opens the preferred mail composer with all selected contacts as 165 Opens the preferred mail composer with all selected contacts as
166 arguments. 166 arguments.
167 */ 167 */
168 void sendMail(); 168 void sendMail();
169 169
170 /** 170 /**
171 Opens the preferred mail composer with the given contacts as 171 Opens the preferred mail composer with the given contacts as
172 arguments. 172 arguments.
173 */ 173 */
174 void sendMail( const QString& email ); 174 void sendMail( const QString& email );
175 175
176 176
177 void mailVCard(); 177 void mailVCard();
178 void mailVCard(const QStringList& uids); 178 void mailVCard(const QStringList& uids);
179 179
180 /** 180 /**
181 Beams the "WhoAmI contact. 181 Beams the "WhoAmI contact.
182 */ 182 */
183 void beamMySelf(); 183 void beamMySelf();
184 184
185 void beamVCard(); 185 void beamVCard();
186 void export2phone(); 186 void export2phone();
187 void beamVCard(const QStringList& uids); 187 void beamVCard(const QStringList& uids);
188 void beamDone( Ir *ir ); 188 void beamDone( Ir *ir );
189 189
190 190
191 /** 191 /**
192 Starts the preferred web browser with the given URL as argument. 192 Starts the preferred web browser with the given URL as argument.
193 */ 193 */
194 void browse( const QString& url ); 194 void browse( const QString& url );
195 195
196 /** 196 /**
197 Select all contacts in the view. 197 Select all contacts in the view.
198 */ 198 */
199 void selectAllContacts(); 199 void selectAllContacts();
200 200
201 /** 201 /**
202 Deletes all selected contacts from the address book. 202 Deletes all selected contacts from the address book.
203 */ 203 */
204 void deleteContacts(); 204 void deleteContacts();
205 205
206 /** 206 /**
207 Deletes given contacts from the address book. 207 Deletes given contacts from the address book.
208 208
209 @param uids The uids of the contacts, which shall be deleted. 209 @param uids The uids of the contacts, which shall be deleted.
210 */ 210 */
211 void deleteContacts( const QStringList &uids ); 211 void deleteContacts( const QStringList &uids );
212 212
213 /** 213 /**
214 Copys the selected contacts into clipboard for later pasting. 214 Copys the selected contacts into clipboard for later pasting.
215 */ 215 */
216 void copyContacts(); 216 void copyContacts();
217 217
218 /** 218 /**
219 Cuts the selected contacts and stores them for later pasting. 219 Cuts the selected contacts and stores them for later pasting.
220 */ 220 */
221 void cutContacts(); 221 void cutContacts();
222 222
223 /** 223 /**
224 Paste contacts from clipboard into the address book. 224 Paste contacts from clipboard into the address book.
225 */ 225 */
226 void pasteContacts(); 226 void pasteContacts();
227 227
228 /** 228 /**
229 Paste given contacts into the address book. 229 Paste given contacts into the address book.
230 230
231 @param list The list of addressee, which shall be pasted. 231 @param list The list of addressee, which shall be pasted.
232 */ 232 */
233 void pasteContacts( KABC::Addressee::List &list ); 233 void pasteContacts( KABC::Addressee::List &list );
234 234
235 /** 235 /**
236 Sets the whoAmI contact, that is used by many other programs to 236 Sets the whoAmI contact, that is used by many other programs to
237 get personal information about the current user. 237 get personal information about the current user.
238 */ 238 */
239 void setWhoAmI(); 239 void setWhoAmI();
240 240
241 /** 241 /**
242 Displays the category dialog and applies the result to all 242 Displays the category dialog and applies the result to all
243 selected contacts. 243 selected contacts.
244 */ 244 */
245 void setCategories(); 245 void setCategories();
246 void manageCategories(); 246 void manageCategories();
247 void editCategories(); 247 void editCategories();
248 248
249 /** 249 /**
250 Sets the field list of the Incremental Search Widget. 250 Sets the field list of the Incremental Search Widget.
251 */ 251 */
252 void setSearchFields( const KABC::Field::List &fields ); 252 void setSearchFields( const KABC::Field::List &fields );
253 253
254 /** 254 /**
255 Search with the current search field for a contact, that matches 255 Search with the current search field for a contact, that matches
256 the given text, and selects it in the view. 256 the given text, and selects it in the view.
257 */ 257 */
258 void incrementalSearch( const QString& text ); 258 void incrementalSearch( const QString& text );
259 259
260 /** 260 /**
261 Marks the address book as modified. 261 Marks the address book as modified.
262 */ 262 */
263 void setModified(); 263 void setModified();
264 /** 264 /**
265 Marks the address book as modified without refreshing the view. 265 Marks the address book as modified without refreshing the view.
266 */ 266 */
267 void setModifiedWOrefresh(); 267 void setModifiedWOrefresh();
268 268
269 /** 269 /**
270 Marks the address book as modified concerning the argument. 270 Marks the address book as modified concerning the argument.
271 */ 271 */
272 void setModified( bool modified ); 272 void setModified( bool modified );
273 273
274 /** 274 /**
275 Returns whether the address book is modified. 275 Returns whether the address book is modified.
276 */ 276 */
277 bool modified() const; 277 bool modified() const;
278 278
279 /** 279 /**
280 Called whenever an contact is modified in the contact editor 280 Called whenever an contact is modified in the contact editor
281 dialog or the quick edit. 281 dialog or the quick edit.
282 */ 282 */
283 void contactModified( const KABC::Addressee &addr ); 283 void contactModified( const KABC::Addressee &addr );
284 284
285 /** 285 /**
286 DCOP METHODS. 286 DCOP METHODS.
287 */ 287 */
288 void addEmail( QString addr ); 288 void addEmail( QString addr );
289 void importVCard( const KURL& url, bool showPreview ); 289 void importVCard( const KURL& url, bool showPreview );
290 void importVCard( const QString& vCard, bool showPreview ); 290 void importVCard( const QString& vCard, bool showPreview );
291 void newContact(); 291 void newContact();
292 QString getNameByPhone( const QString& phone ); 292 QString getNameByPhone( const QString& phone );
293 /** 293 /**
294 END DCOP METHODS 294 END DCOP METHODS
295 */ 295 */
296 296
297 /** 297 /**
298 Saves the contents of the AddressBook back to disk. 298 Saves the contents of the AddressBook back to disk.
299 */ 299 */
300 void save(); 300 void save();
301 301
302 /** 302 /**
303 Undos the last command using the undo stack. 303 Undos the last command using the undo stack.
304 */ 304 */
305 void undo(); 305 void undo();
306 306
307 /** 307 /**
308 Redos the last command that was undone, using the redo stack. 308 Redos the last command that was undone, using the redo stack.
309 */ 309 */
310 void redo(); 310 void redo();
311 311
312 /** 312 /**
313 Shows the edit dialog for the given uid. If the uid is QString::null, 313 Shows the edit dialog for the given uid. If the uid is QString::null,
314 the method will try to find a selected addressee in the view. 314 the method will try to find a selected addressee in the view.
315 */ 315 */
316 void editContact( const QString &uid /*US = QString::null*/ ); 316 void editContact( const QString &uid /*US = QString::null*/ );
317//US added a second method without defaultparameter 317//US added a second method without defaultparameter
318 void editContact2(); 318 void editContact2();
319 319
320 /** 320 /**
321 Shows or edits the detail view for the given uid. If the uid is QString::null, 321 Shows or edits the detail view for the given uid. If the uid is QString::null,
322 the method will try to find a selected addressee in the view. 322 the method will try to find a selected addressee in the view.
323 */ 323 */
324 void executeContact( const QString &uid /*US = QString::null*/ ); 324 void executeContact( const QString &uid /*US = QString::null*/ );
325 325
326 /** 326 /**
327 Launches the configuration dialog. 327 Launches the configuration dialog.
328 */ 328 */
329 void openConfigDialog(); 329 void openConfigDialog();
330 330
331 /** 331 /**
332 Launches the ldap search dialog. 332 Launches the ldap search dialog.
333 */ 333 */
334 void openLDAPDialog(); 334 void openLDAPDialog();
335 335
336 /** 336 /**
337 Creates a KAddressBookPrinter, which will display the print 337 Creates a KAddressBookPrinter, which will display the print
338 dialog and do the printing. 338 dialog and do the printing.
339 */ 339 */
340 void print(); 340 void print();
341 341
342 /** 342 /**
343 Registers a new GUI client, so plugins can register its actions. 343 Registers a new GUI client, so plugins can register its actions.
344 */ 344 */
345 void addGUIClient( KXMLGUIClient *client ); 345 void addGUIClient( KXMLGUIClient *client );
346 346
347 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 347 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
348 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 348 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
349 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 349 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
350 350
351 351
352 signals: 352 signals:
353 void contactSelected( const QString &name ); 353 void contactSelected( const QString &name );
354 void contactSelected( const QPixmap &pixmap ); 354 void contactSelected( const QPixmap &pixmap );
355 public slots: 355 public slots:
356 void recieve(QString cmsg ); 356 void recieve(QString cmsg );
357 void getFile( bool success ); 357 void getFile( bool success );
358 void syncFileRequest(); 358 void syncFileRequest();
359 void setDetailsVisible( bool visible ); 359 void setDetailsVisible( bool visible );
360 void setDetailsToState(); 360 void setDetailsToState();
361 // void slotSyncMenu( int ); 361 // void slotSyncMenu( int );
362 private slots: 362 private slots:
363 void updateToolBar(); 363 void updateToolBar();
364 void updateMainWindow();
364 void receive( const QCString& cmsg, const QByteArray& data ); 365 void receive( const QCString& cmsg, const QByteArray& data );
365 void toggleBeamReceive( ); 366 void toggleBeamReceive( );
366 void disableBR(bool); 367 void disableBR(bool);
367 void setJumpButtonBarVisible( bool visible ); 368 void setJumpButtonBarVisible( bool visible );
368 void setCaptionBack(); 369 void setCaptionBack();
369 void importFromOL(); 370 void importFromOL();
370 void extensionModified( const KABC::Addressee::List &list ); 371 void extensionModified( const KABC::Addressee::List &list );
371 void extensionChanged( int id ); 372 void extensionChanged( int id );
372 void clipboardDataChanged(); 373 void clipboardDataChanged();
373 void updateActionMenu(); 374 void updateActionMenu();
374 void configureKeyBindings(); 375 void configureKeyBindings();
375 void removeVoice(); 376 void removeVoice();
376#ifdef KAB_EMBEDDED 377#ifdef KAB_EMBEDDED
377 void configureResources(); 378 void configureResources();
378#endif //KAB_EMBEDDED 379#endif //KAB_EMBEDDED
379 380
380 void slotEditorDestroyed( const QString &uid ); 381 void slotEditorDestroyed( const QString &uid );
381 void configurationChanged(); 382 void configurationChanged();
382 void addressBookChanged(); 383 void addressBookChanged();
383 384
384 private: 385 private:
385 void resizeEvent(QResizeEvent* e ); 386 void resizeEvent(QResizeEvent* e );
386 bool mBRdisabled; 387 bool mBRdisabled;
387#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
388 QCopChannel* infrared; 389 QCopChannel* infrared;
389#endif 390#endif
390 QTimer *mMessageTimer; 391 QTimer *mMessageTimer;
391 void initGUI(); 392 void initGUI();
392 void initActions(); 393 void initActions();
393 QString getPhoneFile(); 394 QString getPhoneFile();
394 395
395 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 396 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
396 const char *name = 0 ); 397 const char *name = 0 );
397 398
398 KXMLGUIClient *mGUIClient; 399 KXMLGUIClient *mGUIClient;
399 400
400 KABC::AddressBook *mAddressBook; 401 KABC::AddressBook *mAddressBook;
401 402
402 ViewManager *mViewManager; 403 ViewManager *mViewManager;
403 // QSplitter *mDetailsSplitter; 404 // QSplitter *mDetailsSplitter;
404 KDGanttMinimizeSplitter *mExtensionBarSplitter; 405 KDGanttMinimizeSplitter *mExtensionBarSplitter;
405 ViewContainer *mDetails; 406 ViewContainer *mDetails;
406 KDGanttMinimizeSplitter* mMiniSplitter; 407 KDGanttMinimizeSplitter* mMiniSplitter;
407 XXPortManager *mXXPortManager; 408 XXPortManager *mXXPortManager;
408 JumpButtonBar *mJumpButtonBar; 409 JumpButtonBar *mJumpButtonBar;
409 IncSearchWidget *mIncSearchWidget; 410 IncSearchWidget *mIncSearchWidget;
410 ExtensionManager *mExtensionManager; 411 ExtensionManager *mExtensionManager;
411 412
412 KCMultiDialog *mConfigureDialog; 413 KCMultiDialog *mConfigureDialog;
413 414
414#ifndef KAB_EMBEDDED 415#ifndef KAB_EMBEDDED
415 LDAPSearchDialog *mLdapSearchDialog; 416 LDAPSearchDialog *mLdapSearchDialog;
416#endif //KAB_EMBEDDED 417#endif //KAB_EMBEDDED
417 // QDict<AddresseeEditorDialog> mEditorDict; 418 // QDict<AddresseeEditorDialog> mEditorDict;
418 AddresseeEditorDialog *mEditorDialog; 419 AddresseeEditorDialog *mEditorDialog;
419 bool mReadWrite; 420 bool mReadWrite;
420 bool mModified; 421 bool mModified;
421 bool mIsPart; 422 bool mIsPart;
422 bool mMultipleViewsAtOnce; 423 bool mMultipleViewsAtOnce;
423 424
424 425
425 //US file menu 426 //US file menu
426 KAction *mActionMail; 427 KAction *mActionMail;
427 KAction *mActionBeam; 428 KAction *mActionBeam;
428 KToggleAction *mActionBR; 429 KToggleAction *mActionBR;
429 KAction *mActionExport2phone; 430 KAction *mActionExport2phone;
430 KAction* mActionPrint; 431 KAction* mActionPrint;
431 KAction* mActionNewContact; 432 KAction* mActionNewContact;
432 KAction *mActionSave; 433 KAction *mActionSave;
433 KAction *mActionEditAddressee; 434 KAction *mActionEditAddressee;
434 KAction *mActionMailVCard; 435 KAction *mActionMailVCard;
435 KAction *mActionBeamVCard; 436 KAction *mActionBeamVCard;
436 437
437 KAction *mActionQuit; 438 KAction *mActionQuit;
438 439
439 //US edit menu 440 //US edit menu
440 KAction *mActionCopy; 441 KAction *mActionCopy;
441 KAction *mActionCut; 442 KAction *mActionCut;
442 KAction *mActionPaste; 443 KAction *mActionPaste;
443 KAction *mActionSelectAll; 444 KAction *mActionSelectAll;
444 KAction *mActionUndo; 445 KAction *mActionUndo;
445 KAction *mActionRedo; 446 KAction *mActionRedo;
446 KAction *mActionDelete; 447 KAction *mActionDelete;
447 448
448 //US settings menu 449 //US settings menu
449 KAction *mActionConfigResources; 450 KAction *mActionConfigResources;
450 KAction *mActionConfigKAddressbook; 451 KAction *mActionConfigKAddressbook;
451 KAction *mActionConfigShortcuts; 452 KAction *mActionConfigShortcuts;
452 KAction *mActionConfigureToolbars; 453 KAction *mActionConfigureToolbars;
453 KAction *mActionKeyBindings; 454 KAction *mActionKeyBindings;
454 KToggleAction *mActionJumpBar; 455 KToggleAction *mActionJumpBar;
455 KToggleAction *mActionDetails; 456 KToggleAction *mActionDetails;
456 KAction *mActionWhoAmI; 457 KAction *mActionWhoAmI;
457 KAction *mActionCategories; 458 KAction *mActionCategories;
458 KAction *mActionEditCategories; 459 KAction *mActionEditCategories;
459 KAction *mActionManageCategories; 460 KAction *mActionManageCategories;
460 KAction *mActionAboutKAddressbook; 461 KAction *mActionAboutKAddressbook;
461 KAction *mActionLicence; 462 KAction *mActionLicence;
462 KAction *mActionFaq; 463 KAction *mActionFaq;
463 KAction *mActionWN; 464 KAction *mActionWN;
464 KAction *mActionSyncHowto; 465 KAction *mActionSyncHowto;
465 KAction *mActionKdeSyncHowto; 466 KAction *mActionKdeSyncHowto;
466 KAction *mActionMultiSyncHowto; 467 KAction *mActionMultiSyncHowto;
467 468
468 KAction *mActionDeleteView; 469 KAction *mActionDeleteView;
469 470
470 QPopupMenu *viewMenu; 471 QPopupMenu *viewMenu;
471 QPopupMenu *filterMenu; 472 QPopupMenu *filterMenu;
472 QPopupMenu *settingsMenu; 473 QPopupMenu *settingsMenu;
473 QPopupMenu *changeMenu; 474 QPopupMenu *changeMenu;
474//US QAction *mActionSave; 475//US QAction *mActionSave;
475 QPopupMenu *ImportMenu; 476 QPopupMenu *ImportMenu;
476 QPopupMenu *ExportMenu; 477 QPopupMenu *ExportMenu;
477 //LR additional methods 478 //LR additional methods
478 KAction *mActionRemoveVoice; 479 KAction *mActionRemoveVoice;
479 KAction * mActionImportOL; 480 KAction * mActionImportOL;
480 481
481#ifndef KAB_EMBEDDED 482#ifndef KAB_EMBEDDED
482 KAddressBookService *mAddressBookService; 483 KAddressBookService *mAddressBookService;
483#endif //KAB_EMBEDDED 484#endif //KAB_EMBEDDED
484 485
485 class KABCorePrivate; 486 class KABCorePrivate;
486 KABCorePrivate *d; 487 KABCorePrivate *d;
487 //US bool mBlockSaveFlag; 488 //US bool mBlockSaveFlag;
488 489
489#ifdef KAB_EMBEDDED 490#ifdef KAB_EMBEDDED
490 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 491 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
491#endif //KAB_EMBEDDED 492#endif //KAB_EMBEDDED
492 493
493 //this are the overwritten callbackmethods from the syncinterface 494 //this are the overwritten callbackmethods from the syncinterface
494 virtual bool sync(KSyncManager* manager, QString filename, int mode); 495 virtual bool sync(KSyncManager* manager, QString filename, int mode);
495 virtual bool syncExternal(KSyncManager* manager, QString resource); 496 virtual bool syncExternal(KSyncManager* manager, QString resource);
496 virtual void removeSyncInfo( QString syncProfile); 497 virtual void removeSyncInfo( QString syncProfile);
497 bool syncPhone(); 498 bool syncPhone();
498 void message( QString m ); 499 void message( QString m );
499 500
500 // LR ******************************* 501 // LR *******************************
501 // sync stuff! 502 // sync stuff!
502 QString sentSyncFile(); 503 QString sentSyncFile();
503 QPopupMenu *syncMenu; 504 QPopupMenu *syncMenu;
504 KSyncManager* syncManager; 505 KSyncManager* syncManager;
505 int mGlobalSyncMode; 506 int mGlobalSyncMode;
506 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 507 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
507 KABC::Addressee getLastSyncAddressee(); 508 KABC::Addressee getLastSyncAddressee();
508 QDateTime mLastAddressbookSync; 509 QDateTime mLastAddressbookSync;
509 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 510 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
510 // ********************* 511 // *********************
511 512
512}; 513};
513 514
514#endif 515#endif
diff --git a/kmicromail/libetpan/mime/mailmime_decode.c b/kmicromail/libetpan/mime/mailmime_decode.c
index b2ab0f7..bb7638e 100644
--- a/kmicromail/libetpan/mime/mailmime_decode.c
+++ b/kmicromail/libetpan/mime/mailmime_decode.c
@@ -1,559 +1,559 @@
1/* 1/*
2 * libEtPan! -- a mail stuff library 2 * libEtPan! -- a mail stuff library
3 * 3 *
4 * Copyright (C) 2001, 2002 - DINH Viet Hoa 4 * Copyright (C) 2001, 2002 - DINH Viet Hoa
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the libEtPan! project nor the names of its 15 * 3. Neither the name of the libEtPan! project nor the names of its
16 * contributors may be used to endorse or promote products derived 16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission. 17 * from this software without specific prior written permission.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * $Id$ 33 * $Id$
34 */ 34 */
35 35
36/* 36/*
37 RFC 2047 : MIME (Multipurpose Internet Mail Extensions) Part Three: 37 RFC 2047 : MIME (Multipurpose Internet Mail Extensions) Part Three:
38 Message Header Extensions for Non-ASCII Text 38 Message Header Extensions for Non-ASCII Text
39*/ 39*/
40 40
41#include "mailmime_decode.h" 41#include "mailmime_decode.h"
42 42
43#include <ctype.h> 43#include <ctype.h>
44#include <unistd.h> 44#include <unistd.h>
45#include <sys/mman.h> 45#include <sys/mman.h>
46#include <string.h> 46#include <string.h>
47#include <stdlib.h> 47#include <stdlib.h>
48 48
49#include "mailmime_content.h" 49#include "mailmime_content.h"
50 50
51#include "charconv.h" 51#include "charconv.h"
52#include "mmapstring.h" 52#include "mmapstring.h"
53#include "mailimf.h" 53#include "mailimf.h"
54 54
55#ifndef TRUE 55#ifndef TRUE
56#define TRUE 1 56#define TRUE 1
57#endif 57#endif
58 58
59#ifndef FALSE 59#ifndef FALSE
60#define FALSE 0 60#define FALSE 0
61#endif 61#endif
62 62
63static int mailmime_charset_parse(const char * message, size_t length, 63static int mailmime_charset_parse(const char * message, size_t length,
64 size_t * index, char ** charset); 64 size_t * index, char ** charset);
65 65
66enum { 66enum {
67 MAILMIME_ENCODING_B, 67 MAILMIME_ENCODING_B,
68 MAILMIME_ENCODING_Q 68 MAILMIME_ENCODING_Q
69}; 69};
70 70
71static int mailmime_encoding_parse(const char * message, size_t length, 71static int mailmime_encoding_parse(const char * message, size_t length,
72 size_t * index, int * result); 72 size_t * index, int * result);
73 73
74static int mailmime_etoken_parse(const char * message, size_t length, 74static int mailmime_etoken_parse(const char * message, size_t length,
75 size_t * index, char ** result); 75 size_t * index, char ** result);
76 76
77static int 77static int
78mailmime_non_encoded_word_parse(const char * message, size_t length, 78mailmime_non_encoded_word_parse(const char * message, size_t length,
79 size_t * index, 79 size_t * index,
80 char ** result); 80 char ** result);
81 81
82static int 82static int
83mailmime_encoded_word_parse(const char * message, size_t length, 83mailmime_encoded_word_parse(const char * message, size_t length,
84 size_t * index, 84 size_t * index,
85 struct mailmime_encoded_word ** result); 85 struct mailmime_encoded_word ** result);
86 86
87 87
88enum { 88enum {
89 TYPE_ERROR, 89 TYPE_ERROR,
90 TYPE_WORD, 90 TYPE_WORD,
91 TYPE_ENCODED_WORD, 91 TYPE_ENCODED_WORD,
92}; 92};
93 93
94int mailmime_encoded_phrase_parse(const char * default_fromcode, 94int mailmime_encoded_phrase_parse(const char * default_fromcode,
95 const char * message, size_t length, 95 const char * message, size_t length,
96 size_t * index, const char * tocode, 96 size_t * index, const char * tocode,
97 char ** result) 97 char ** result)
98{ 98{
99 MMAPString * gphrase; 99 MMAPString * gphrase;
100 struct mailmime_encoded_word * word; 100 struct mailmime_encoded_word * word;
101 int first; 101 int first;
102 size_t cur_token; 102 size_t cur_token;
103 int r; 103 int r;
104 int res; 104 int res;
105 char * str; 105 char * str;
106 char * wordutf8; 106 char * wordutf8;
107 int type; 107 int type;
108 108 int appendNewLine;
109 cur_token = * index; 109 cur_token = * index;
110 110
111 gphrase = mmap_string_new(""); 111 gphrase = mmap_string_new("");
112 if (gphrase == NULL) { 112 if (gphrase == NULL) {
113 res = MAILIMF_ERROR_MEMORY; 113 res = MAILIMF_ERROR_MEMORY;
114 goto err; 114 goto err;
115 } 115 }
116 116
117 first = TRUE; 117 first = TRUE;
118 118
119 type = TYPE_ERROR; /* XXX - removes a gcc warning */ 119 type = TYPE_ERROR; /* XXX - removes a gcc warning */
120 // LUTZ add 120 /* LUTZ add*/
121 int appendNewLine = FALSE; 121 appendNewLine = FALSE;
122 while (1) { //while 122 while (1) {
123 123
124 r = mailmime_encoded_word_parse(message, length, &cur_token, &word); 124 r = mailmime_encoded_word_parse(message, length, &cur_token, &word);
125 if (r == MAILIMF_NO_ERROR) { 125 if (r == MAILIMF_NO_ERROR) {
126 if (!first) { 126 if (!first) {
127 if (type != TYPE_ENCODED_WORD) { 127 if (type != TYPE_ENCODED_WORD) {
128 if (mmap_string_append_c(gphrase, ' ') == NULL) { 128 if (mmap_string_append_c(gphrase, ' ') == NULL) {
129 mailmime_encoded_word_free(word); 129 mailmime_encoded_word_free(word);
130 res = MAILIMF_ERROR_MEMORY; 130 res = MAILIMF_ERROR_MEMORY;
131 goto free; 131 goto free;
132 } 132 }
133 } 133 }
134 } 134 }
135 type = TYPE_ENCODED_WORD; 135 type = TYPE_ENCODED_WORD;
136 wordutf8 = NULL; 136 wordutf8 = NULL;
137 r = charconv(tocode, word->wd_charset, word->wd_text, 137 r = charconv(tocode, word->wd_charset, word->wd_text,
138 strlen(word->wd_text), &wordutf8); 138 strlen(word->wd_text), &wordutf8);
139 switch (r) { 139 switch (r) {
140 case MAIL_CHARCONV_ERROR_MEMORY: 140 case MAIL_CHARCONV_ERROR_MEMORY:
141 mailmime_encoded_word_free(word); 141 mailmime_encoded_word_free(word);
142 res = MAILIMF_ERROR_MEMORY; 142 res = MAILIMF_ERROR_MEMORY;
143 goto free; 143 goto free;
144 144
145 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: 145 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
146 case MAIL_CHARCONV_ERROR_CONV: 146 case MAIL_CHARCONV_ERROR_CONV:
147 mailmime_encoded_word_free(word); 147 mailmime_encoded_word_free(word);
148 res = MAILIMF_ERROR_PARSE; 148 res = MAILIMF_ERROR_PARSE;
149 goto free; 149 goto free;
150 } 150 }
151 151
152 if (wordutf8 != NULL) { 152 if (wordutf8 != NULL) {
153 if (mmap_string_append(gphrase, wordutf8) == NULL) { 153 if (mmap_string_append(gphrase, wordutf8) == NULL) {
154 mailmime_encoded_word_free(word); 154 mailmime_encoded_word_free(word);
155 free(wordutf8); 155 free(wordutf8);
156 res = MAILIMF_ERROR_MEMORY; 156 res = MAILIMF_ERROR_MEMORY;
157 goto free; 157 goto free;
158 } 158 }
159 free(wordutf8); 159 free(wordutf8);
160 } 160 }
161 mailmime_encoded_word_free(word); 161 mailmime_encoded_word_free(word);
162 first = FALSE; 162 first = FALSE;
163 } 163 }
164 else if (r == MAILIMF_ERROR_PARSE) { 164 else if (r == MAILIMF_ERROR_PARSE) {
165 /* do nothing */ 165 /* do nothing */
166 } 166 }
167 else { 167 else {
168 res = r; 168 res = r;
169 goto free; 169 goto free;
170 } 170 }
171 171
172 if (r == MAILIMF_ERROR_PARSE) { 172 if (r == MAILIMF_ERROR_PARSE) {
173 char * raw_word; 173 char * raw_word;
174 174
175 r = mailmime_non_encoded_word_parse(message, length, 175 r = mailmime_non_encoded_word_parse(message, length,
176 &cur_token, &raw_word); 176 &cur_token, &raw_word);
177 if (r == MAILIMF_NO_ERROR) { 177 if (r == MAILIMF_NO_ERROR) {
178 if (!first) { 178 if (!first) {
179 if (mmap_string_append_c(gphrase, ' ') == NULL) { 179 if (mmap_string_append_c(gphrase, ' ') == NULL) {
180 free(raw_word); 180 free(raw_word);
181 res = MAILIMF_ERROR_MEMORY; 181 res = MAILIMF_ERROR_MEMORY;
182 goto free; 182 goto free;
183 } 183 }
184 } 184 }
185 type = TYPE_WORD; 185 type = TYPE_WORD;
186 186
187 wordutf8 = NULL; 187 wordutf8 = NULL;
188 r = charconv(tocode, default_fromcode, raw_word, 188 r = charconv(tocode, default_fromcode, raw_word,
189 strlen(raw_word), &wordutf8); 189 strlen(raw_word), &wordutf8);
190 190
191 switch (r) { 191 switch (r) {
192 case MAIL_CHARCONV_ERROR_MEMORY: 192 case MAIL_CHARCONV_ERROR_MEMORY:
193 free(raw_word); 193 free(raw_word);
194 res = MAILIMF_ERROR_MEMORY; 194 res = MAILIMF_ERROR_MEMORY;
195 goto free; 195 goto free;
196 196
197 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: 197 case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
198 case MAIL_CHARCONV_ERROR_CONV: 198 case MAIL_CHARCONV_ERROR_CONV:
199 free(raw_word); 199 free(raw_word);
200 res = MAILIMF_ERROR_PARSE; 200 res = MAILIMF_ERROR_PARSE;
201 goto free; 201 goto free;
202 } 202 }
203 // LUTZ add 203 // LUTZ add
204 if ( appendNewLine ) { 204 if ( appendNewLine ) {
205 appendNewLine = FALSE; 205 appendNewLine = FALSE;
206 if (mmap_string_append(gphrase, "\n") == NULL) { 206 if (mmap_string_append(gphrase, "\n") == NULL) {
207 free(wordutf8); 207 free(wordutf8);
208 free(raw_word); 208 free(raw_word);
209 res = MAILIMF_ERROR_MEMORY; 209 res = MAILIMF_ERROR_MEMORY;
210 goto free; 210 goto free;
211 } 211 }
212 } 212 }
213 //fprintf(stderr,"append *%s* \n",wordutf8 ); 213 //fprintf(stderr,"append *%s* \n",wordutf8 );
214 if (mmap_string_append(gphrase, wordutf8) == NULL) { 214 if (mmap_string_append(gphrase, wordutf8) == NULL) {
215 free(wordutf8); 215 free(wordutf8);
216 free(raw_word); 216 free(raw_word);
217 res = MAILIMF_ERROR_MEMORY; 217 res = MAILIMF_ERROR_MEMORY;
218 goto free; 218 goto free;
219 } 219 }
220 // LUTZ fix 220 // LUTZ fix
221 free(wordutf8); 221 free(wordutf8);
222 free(raw_word); 222 free(raw_word);
223 first = FALSE; 223 first = FALSE;
224 } 224 }
225 else if (r == MAILIMF_ERROR_PARSE) { 225 else if (r == MAILIMF_ERROR_PARSE) {
226 // LUTZ add 226 // LUTZ add
227 if ( cur_token >= length ) 227 if ( cur_token >= length )
228 break; 228 break;
229 ++cur_token; 229 ++cur_token;
230 appendNewLine = TRUE; 230 appendNewLine = TRUE;
231 } 231 }
232 else { 232 else {
233 res = r; 233 res = r;
234 goto free; 234 goto free;
235 } 235 }
236 } 236 }
237 } 237 }
238 238
239 if (first) { 239 if (first) {
240 res = MAILIMF_ERROR_PARSE; 240 res = MAILIMF_ERROR_PARSE;
241 goto free; 241 goto free;
242 } 242 }
243 243
244 str = strdup(gphrase->str); 244 str = strdup(gphrase->str);
245 if (str == NULL) { 245 if (str == NULL) {
246 res = MAILIMF_ERROR_MEMORY; 246 res = MAILIMF_ERROR_MEMORY;
247 goto free; 247 goto free;
248 } 248 }
249 mmap_string_free(gphrase); 249 mmap_string_free(gphrase);
250 250
251 * result = str; 251 * result = str;
252 * index = cur_token; 252 * index = cur_token;
253 253
254 return MAILIMF_NO_ERROR; 254 return MAILIMF_NO_ERROR;
255 255
256 free: 256 free:
257 mmap_string_free(gphrase); 257 mmap_string_free(gphrase);
258 err: 258 err:
259 return res; 259 return res;
260} 260}
261 261
262static int 262static int
263mailmime_non_encoded_word_parse(const char * message, size_t length, 263mailmime_non_encoded_word_parse(const char * message, size_t length,
264 size_t * index, 264 size_t * index,
265 char ** result) 265 char ** result)
266{ 266{
267 int end; 267 int end;
268 size_t cur_token; 268 size_t cur_token;
269 int res; 269 int res;
270 char * text; 270 char * text;
271 int r; 271 int r;
272 size_t begin; 272 size_t begin;
273 273
274 cur_token = * index; 274 cur_token = * index;
275 275
276 r = mailimf_fws_parse(message, length, &cur_token); 276 r = mailimf_fws_parse(message, length, &cur_token);
277 if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { 277 if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
278 res = r; 278 res = r;
279 goto err; 279 goto err;
280 } 280 }
281 281
282 begin = cur_token; 282 begin = cur_token;
283 283
284 end = FALSE; 284 end = FALSE;
285 while (1) { 285 while (1) {
286 if (cur_token >= length) 286 if (cur_token >= length)
287 break; 287 break;
288 288
289 switch (message[cur_token]) { 289 switch (message[cur_token]) {
290 case ' ': 290 case ' ':
291 case '\t': 291 case '\t':
292 case '\r': 292 case '\r':
293 case '\n': 293 case '\n':
294 end = TRUE; 294 end = TRUE;
295 break; 295 break;
296 } 296 }
297 297
298 if (end) 298 if (end)
299 break; 299 break;
300 300
301 cur_token ++; 301 cur_token ++;
302 } 302 }
303 303
304 if (cur_token - begin == 0) { 304 if (cur_token - begin == 0) {
305 res = MAILIMF_ERROR_PARSE; 305 res = MAILIMF_ERROR_PARSE;
306 goto err; 306 goto err;
307 } 307 }
308 308
309 text = malloc(cur_token - begin + 1); 309 text = malloc(cur_token - begin + 1);
310 if (text == NULL) { 310 if (text == NULL) {
311 res = MAILIMF_ERROR_MEMORY; 311 res = MAILIMF_ERROR_MEMORY;
312 goto err; 312 goto err;
313 } 313 }
314 314
315 memcpy(text, message + begin, cur_token - begin); 315 memcpy(text, message + begin, cur_token - begin);
316 text[cur_token - begin] = '\0'; 316 text[cur_token - begin] = '\0';
317 317
318 * index = cur_token; 318 * index = cur_token;
319 * result = text; 319 * result = text;
320 320
321 return MAILIMF_NO_ERROR; 321 return MAILIMF_NO_ERROR;
322 322
323 err: 323 err:
324 return res; 324 return res;
325} 325}
326 326
327static int mailmime_encoded_word_parse(const char * message, size_t length, 327static int mailmime_encoded_word_parse(const char * message, size_t length,
328 size_t * index, 328 size_t * index,
329 struct mailmime_encoded_word ** result) 329 struct mailmime_encoded_word ** result)
330{ 330{
331 size_t cur_token; 331 size_t cur_token;
332 char * charset; 332 char * charset;
333 int encoding; 333 int encoding;
334 char * text; 334 char * text;
335 size_t end_encoding; 335 size_t end_encoding;
336 char * decoded; 336 char * decoded;
337 size_t decoded_len; 337 size_t decoded_len;
338 struct mailmime_encoded_word * ew; 338 struct mailmime_encoded_word * ew;
339 int r; 339 int r;
340 int res; 340 int res;
341 int opening_quote; 341 int opening_quote;
342 int end; 342 int end;
343 343
344 cur_token = * index; 344 cur_token = * index;
345 345
346 r = mailimf_fws_parse(message, length, &cur_token); 346 r = mailimf_fws_parse(message, length, &cur_token);
347 if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { 347 if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
348 res = r; 348 res = r;
349 goto err; 349 goto err;
350 } 350 }
351 351
352 opening_quote = FALSE; 352 opening_quote = FALSE;
353 r = mailimf_char_parse(message, length, &cur_token, '\"'); 353 r = mailimf_char_parse(message, length, &cur_token, '\"');
354 if (r == MAILIMF_NO_ERROR) { 354 if (r == MAILIMF_NO_ERROR) {
355 opening_quote = TRUE; 355 opening_quote = TRUE;
356 } 356 }
357 else if (r == MAILIMF_ERROR_PARSE) { 357 else if (r == MAILIMF_ERROR_PARSE) {
358 /* do nothing */ 358 /* do nothing */
359 } 359 }
360 else { 360 else {
361 res = r; 361 res = r;
362 goto err; 362 goto err;
363 } 363 }
364 364
365 r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "=?"); 365 r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "=?");
366 if (r != MAILIMF_NO_ERROR) { 366 if (r != MAILIMF_NO_ERROR) {
367 res = r; 367 res = r;
368 goto err; 368 goto err;
369 } 369 }
370 370
371 r = mailmime_charset_parse(message, length, &cur_token, &charset); 371 r = mailmime_charset_parse(message, length, &cur_token, &charset);
372 if (r != MAILIMF_NO_ERROR) { 372 if (r != MAILIMF_NO_ERROR) {
373 res = r; 373 res = r;
374 goto err; 374 goto err;
375 } 375 }
376 376
377 r = mailimf_char_parse(message, length, &cur_token, '?'); 377 r = mailimf_char_parse(message, length, &cur_token, '?');
378 if (r != MAILIMF_NO_ERROR) { 378 if (r != MAILIMF_NO_ERROR) {
379 res = r; 379 res = r;
380 goto free_charset; 380 goto free_charset;
381 } 381 }
382 382
383 r = mailmime_encoding_parse(message, length, &cur_token, &encoding); 383 r = mailmime_encoding_parse(message, length, &cur_token, &encoding);
384 if (r != MAILIMF_NO_ERROR) { 384 if (r != MAILIMF_NO_ERROR) {
385 res = r; 385 res = r;
386 goto free_charset; 386 goto free_charset;
387 } 387 }
388 388
389 r = mailimf_char_parse(message, length, &cur_token, '?'); 389 r = mailimf_char_parse(message, length, &cur_token, '?');
390 if (r != MAILIMF_NO_ERROR) { 390 if (r != MAILIMF_NO_ERROR) {
391 res = r; 391 res = r;
392 goto free_charset; 392 goto free_charset;
393 } 393 }
394 394
395 end = FALSE; 395 end = FALSE;
396 end_encoding = cur_token; 396 end_encoding = cur_token;
397 while (1) { 397 while (1) {
398 if (end_encoding >= length) 398 if (end_encoding >= length)
399 break; 399 break;
400 400
401 switch (message[end_encoding]) { 401 switch (message[end_encoding]) {
402 case '?': 402 case '?':
403#if 0 403#if 0
404 case ' ': 404 case ' ':
405#endif 405#endif
406 end = TRUE; 406 end = TRUE;
407 break; 407 break;
408 } 408 }
409 409
410 if (end) 410 if (end)
411 break; 411 break;
412 412
413 end_encoding ++; 413 end_encoding ++;
414 } 414 }
415 415
416 decoded_len = 0; 416 decoded_len = 0;
417 decoded = NULL; 417 decoded = NULL;
418 switch (encoding) { 418 switch (encoding) {
419 case MAILMIME_ENCODING_B: 419 case MAILMIME_ENCODING_B:
420 r = mailmime_base64_body_parse(message, end_encoding, 420 r = mailmime_base64_body_parse(message, end_encoding,
421 &cur_token, &decoded, 421 &cur_token, &decoded,
422 &decoded_len); 422 &decoded_len);
423 423
424 if (r != MAILIMF_NO_ERROR) { 424 if (r != MAILIMF_NO_ERROR) {
425 res = r; 425 res = r;
426 goto free_charset; 426 goto free_charset;
427 } 427 }
428 break; 428 break;
429 case MAILMIME_ENCODING_Q: 429 case MAILMIME_ENCODING_Q:
430 r = mailmime_quoted_printable_body_parse(message, end_encoding, 430 r = mailmime_quoted_printable_body_parse(message, end_encoding,
431 &cur_token, &decoded, 431 &cur_token, &decoded,
432 &decoded_len, TRUE); 432 &decoded_len, TRUE);
433 433
434 if (r != MAILIMF_NO_ERROR) { 434 if (r != MAILIMF_NO_ERROR) {
435 res = r; 435 res = r;
436 goto free_charset; 436 goto free_charset;
437 } 437 }
438 438
439 break; 439 break;
440 } 440 }
441 441
442 text = malloc(decoded_len + 1); 442 text = malloc(decoded_len + 1);
443 if (text == NULL) { 443 if (text == NULL) {
444 res = MAILIMF_ERROR_MEMORY; 444 res = MAILIMF_ERROR_MEMORY;
445 goto free_charset; 445 goto free_charset;
446 } 446 }
447 447
448 if (decoded_len > 0) 448 if (decoded_len > 0)
449 memcpy(text, decoded, decoded_len); 449 memcpy(text, decoded, decoded_len);
450 text[decoded_len] = '\0'; 450 text[decoded_len] = '\0';
451 451
452 mailmime_decoded_part_free(decoded); 452 mailmime_decoded_part_free(decoded);
453 453
454 r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "?="); 454 r = mailimf_token_case_insensitive_parse(message, length, &cur_token, "?=");
455 if (r != MAILIMF_NO_ERROR) { 455 if (r != MAILIMF_NO_ERROR) {
456 res = r; 456 res = r;
457 goto free_encoded_text; 457 goto free_encoded_text;
458 } 458 }
459 459
460 if (opening_quote) { 460 if (opening_quote) {
461 r = mailimf_char_parse(message, length, &cur_token, '\"'); 461 r = mailimf_char_parse(message, length, &cur_token, '\"');
462 if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { 462 if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
463 res = r; 463 res = r;
464 goto free_encoded_text; 464 goto free_encoded_text;
465 } 465 }
466 } 466 }
467 467
468 ew = mailmime_encoded_word_new(charset, text); 468 ew = mailmime_encoded_word_new(charset, text);
469 if (ew == NULL) { 469 if (ew == NULL) {
470 res = MAILIMF_ERROR_MEMORY; 470 res = MAILIMF_ERROR_MEMORY;
471 goto free_encoded_text; 471 goto free_encoded_text;
472 } 472 }
473 473
474 * result = ew; 474 * result = ew;
475 * index = cur_token; 475 * index = cur_token;
476 476
477 return MAILIMF_NO_ERROR; 477 return MAILIMF_NO_ERROR;
478 478
479 free_encoded_text: 479 free_encoded_text:
480 mailmime_encoded_text_free(text); 480 mailmime_encoded_text_free(text);
481 free_charset: 481 free_charset:
482 mailmime_charset_free(charset); 482 mailmime_charset_free(charset);
483 err: 483 err:
484 return res; 484 return res;
485} 485}
486 486
487static int mailmime_charset_parse(const char * message, size_t length, 487static int mailmime_charset_parse(const char * message, size_t length,
488 size_t * index, char ** charset) 488 size_t * index, char ** charset)
489{ 489{
490 return mailmime_etoken_parse(message, length, index, charset); 490 return mailmime_etoken_parse(message, length, index, charset);
491} 491}
492 492
493static int mailmime_encoding_parse(const char * message, size_t length, 493static int mailmime_encoding_parse(const char * message, size_t length,
494 size_t * index, int * result) 494 size_t * index, int * result)
495{ 495{
496 size_t cur_token; 496 size_t cur_token;
497 int encoding; 497 int encoding;
498 498
499 cur_token = * index; 499 cur_token = * index;
500 500
501 if (cur_token >= length) 501 if (cur_token >= length)
502 return MAILIMF_ERROR_PARSE; 502 return MAILIMF_ERROR_PARSE;
503 503
504 switch ((char) toupper((unsigned char) message[cur_token])) { 504 switch ((char) toupper((unsigned char) message[cur_token])) {
505 case 'Q': 505 case 'Q':
506 encoding = MAILMIME_ENCODING_Q; 506 encoding = MAILMIME_ENCODING_Q;
507 break; 507 break;
508 case 'B': 508 case 'B':
509 encoding = MAILMIME_ENCODING_B; 509 encoding = MAILMIME_ENCODING_B;
510 break; 510 break;
511 default: 511 default:
512 return MAILIMF_ERROR_INVAL; 512 return MAILIMF_ERROR_INVAL;
513 } 513 }
514 514
515 cur_token ++; 515 cur_token ++;
516 516
517 * result = encoding; 517 * result = encoding;
518 * index = cur_token; 518 * index = cur_token;
519 519
520 return MAILIMF_NO_ERROR; 520 return MAILIMF_NO_ERROR;
521} 521}
522 522
523int is_etoken_char(char ch) 523int is_etoken_char(char ch)
524{ 524{
525 unsigned char uch = ch; 525 unsigned char uch = ch;
526 526
527 if (uch < 31) 527 if (uch < 31)
528 return FALSE; 528 return FALSE;
529 529
530 switch (uch) { 530 switch (uch) {
531 case ' ': 531 case ' ':
532 case '(': 532 case '(':
533 case ')': 533 case ')':
534 case '<': 534 case '<':
535 case '>': 535 case '>':
536 case '@': 536 case '@':
537 case ',': 537 case ',':
538 case ';': 538 case ';':
539 case ':': 539 case ':':
540 case '"': 540 case '"':
541 case '/': 541 case '/':
542 case '[': 542 case '[':
543 case ']': 543 case ']':
544 case '?': 544 case '?':
545 case '.': 545 case '.':
546 case '=': 546 case '=':
547 return FALSE; 547 return FALSE;
548 } 548 }
549 549
550 return TRUE; 550 return TRUE;
551} 551}
552 552
553static int mailmime_etoken_parse(const char * message, size_t length, 553static int mailmime_etoken_parse(const char * message, size_t length,
554 size_t * index, char ** result) 554 size_t * index, char ** result)
555{ 555{
556 return mailimf_custom_string_parse(message, length, 556 return mailimf_custom_string_parse(message, length,
557 index, result, 557 index, result,
558 is_etoken_char); 558 is_etoken_char);
559} 559}