summaryrefslogtreecommitdiffabout
path: root/kaddressbook/mainembedded.cpp
Unidiff
Diffstat (limited to 'kaddressbook/mainembedded.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/mainembedded.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 6dd97b8..a2ff1e9 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,218 +1,215 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#else 5#else
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qwindowsstyle.h> 7#include <qwindowsstyle.h>
8#include <qplatinumstyle.h> 8#include <qplatinumstyle.h>
9#include <qmainwindow.h> 9#include <qmainwindow.h>
10#endif 10#endif
11 11
12#include <kstandarddirs.h> 12#include <kstandarddirs.h>
13#include <qregexp.h> 13#include <qregexp.h>
14#include <kglobal.h> 14#include <kglobal.h>
15#include <stdio.h> 15#include <stdio.h>
16#include <qdir.h> 16#include <qdir.h>
17#include "kaddressbookmain.h" 17#include "kaddressbookmain.h"
18#include "externalapphandler.h" 18#include "externalapphandler.h"
19#include <libkdepim/kpimglobalprefs.h> 19#include <libkdepim/kpimglobalprefs.h>
20 20
21int main( int argc, char **argv ) 21int main( int argc, char **argv )
22{ 22{
23#ifndef DESKTOP_VERSION 23#ifndef DESKTOP_VERSION
24 QPEApplication a( argc, argv ); 24 QPEApplication a( argc, argv );
25 a.setKeepRunning (); 25 a.setKeepRunning ();
26#else 26#else
27 QApplication a( argc, argv ); 27 QApplication a( argc, argv );
28 QApplication::setStyle( new QPlatinumStyle ()); 28 QApplication::setStyle( new QPlatinumStyle ());
29 QString hdir = QDir::homeDirPath(); 29 QString hdir = QDir::homeDirPath();
30 // there is a bug when creating dirs for WIN 98 30 // there is a bug when creating dirs for WIN 98
31 // it is difficult to fix, because we have no WIN 98 runnung 31 // it is difficult to fix, because we have no WIN 98 runnung
32 // such that we try it to create the dirs at startup here 32 // such that we try it to create the dirs at startup here
33 if ( hdir == "C:\\" ) { // win 98 or ME 33 if ( hdir == "C:\\" ) { // win 98 or ME
34 QDir app_dir; 34 QDir app_dir;
35 if ( !app_dir.exists("C:\\kdepim") ) 35 if ( !app_dir.exists("C:\\kdepim") )
36 app_dir.mkdir ("C:\\kdepim"); 36 app_dir.mkdir ("C:\\kdepim");
37 if ( !app_dir.exists("C:\\kdepim\\apps") ) 37 if ( !app_dir.exists("C:\\kdepim\\apps") )
38 app_dir.mkdir ("C:\\kdepim\\apps"); 38 app_dir.mkdir ("C:\\kdepim\\apps");
39 if ( !app_dir.exists("C:\\kdepim\\config") ) 39 if ( !app_dir.exists("C:\\kdepim\\config") )
40 app_dir.mkdir ("C:\\kdepim\\config"); 40 app_dir.mkdir ("C:\\kdepim\\config");
41 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) 41 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
42 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); 42 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
43 } 43 }
44#endif 44#endif
45 45
46 bool exitHelp = false; 46 bool exitHelp = false;
47 if ( argc > 1 ) { 47 if ( argc > 1 ) {
48 QString command = argv[1]; 48 QString command = argv[1];
49 if ( command == "-help" ){ 49 if ( command == "-help" ){
50 printf("KA/E command line commands:\n"); 50 printf("KA/E command line commands:\n");
51 printf(" no command: Start KA/E in usual way\n"); 51 printf(" no command: Start KA/E in usual way\n");
52 printf(" -help: This output\n"); 52 printf(" -help: This output\n");
53 printf(" KA/E is exiting now. Bye!\n"); 53 printf(" KA/E is exiting now. Bye!\n");
54 exitHelp = true; 54 exitHelp = true;
55 } 55 }
56 } 56 }
57 if ( ! exitHelp ) { 57 if ( ! exitHelp ) {
58 58
59 KGlobal::setAppName( "kaddressbook" ); 59 KGlobal::setAppName( "kaddressbook" );
60#ifndef DESKTOP_VERSION 60#ifndef DESKTOP_VERSION
61 if ( QApplication::desktop()->width() > 320 ) 61 if ( QApplication::desktop()->width() > 320 )
62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
63 else 63 else
64 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 64 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
65#else 65#else
66 QString fileName ; 66 QString fileName ;
67 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 67 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
68 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 68 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
69 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 69 QApplication::addLibraryPath ( qApp->applicationDirPath () );
70 70
71#endif 71#endif
72 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 72 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
73 KAddressBookMain m ; 73 KAddressBookMain m ;
74//US MainWindow m; 74//US MainWindow m;
75 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 75 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
76 76
77 { 77 {
78 KPimGlobalPrefs::instance()->setGlobalConfig(); 78 KPimGlobalPrefs::instance()->setGlobalConfig();
79 } 79 }
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 a.showMainWidget( &m ); 81 a.showMainWidget( &m );
82 QCopChannel* c1 = new QCopChannel("QPE/Application/addressbook",&m, "channelAB" ) ; 82
83 QObject::connect( c1, SIGNAL (received ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
84#else 83#else
85 a.setMainWidget( &m ); 84 a.setMainWidget( &m );
86 m.resize (640, 480 ); 85 m.resize (640, 480 );
87 m.show(); 86 m.show();
88#endif 87#endif
89 a.exec(); 88 a.exec();
90#ifndef DESKTOP_VERSION 89
91 delete c1;
92#endif
93 90
94 } 91 }
95 qDebug("KA: Bye! "); 92 qDebug("KA: Bye! ");
96} 93}
97 94
98/* 95/*
99#include <stdlib.h> 96#include <stdlib.h>
100 97
101#include <qstring.h> 98#include <qstring.h>
102 99
103#include <kabc/stdaddressbook.h> 100#include <kabc/stdaddressbook.h>
104#include <kaboutdata.h> 101#include <kaboutdata.h>
105#include <kcmdlineargs.h> 102#include <kcmdlineargs.h>
106#include <kcrash.h> 103#include <kcrash.h>
107#include <kdebug.h> 104#include <kdebug.h>
108#include <klocale.h> 105#include <klocale.h>
109#include <kstartupinfo.h> 106#include <kstartupinfo.h>
110#include <kuniqueapplication.h> 107#include <kuniqueapplication.h>
111#include <kwin.h> 108#include <kwin.h>
112 109
113#include "kaddressbookmain.h" 110#include "kaddressbookmain.h"
114#include "kabcore.h" 111#include "kabcore.h"
115 112
116extern "C" { 113extern "C" {
117 114
118void crashHandler( int ) 115void crashHandler( int )
119{ 116{
120 KABC::StdAddressBook::handleCrash(); 117 KABC::StdAddressBook::handleCrash();
121 ::exit( 0 ); 118 ::exit( 0 );
122} 119}
123 120
124} 121}
125 122
126class KAddressBookApp : public KUniqueApplication { 123class KAddressBookApp : public KUniqueApplication {
127 public: 124 public:
128 KAddressBookApp() : mMainWin( 0 ) {} 125 KAddressBookApp() : mMainWin( 0 ) {}
129 ~KAddressBookApp() {} 126 ~KAddressBookApp() {}
130 127
131 int newInstance(); 128 int newInstance();
132 129
133 private: 130 private:
134 KAddressBookMain *mMainWin; 131 KAddressBookMain *mMainWin;
135}; 132};
136 133
137int KAddressBookApp::newInstance() 134int KAddressBookApp::newInstance()
138{ 135{
139 if ( isRestored() ) { 136 if ( isRestored() ) {
140 // There can only be one main window 137 // There can only be one main window
141 if ( KMainWindow::canBeRestored( 1 ) ) { 138 if ( KMainWindow::canBeRestored( 1 ) ) {
142 mMainWin = new KAddressBookMain; 139 mMainWin = new KAddressBookMain;
143 mMainWin->show(); 140 mMainWin->show();
144 mMainWin->restore( 1 ); 141 mMainWin->restore( 1 );
145 } 142 }
146 } else { 143 } else {
147 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 144 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
148 145
149 QCString addrStr = args->getOption( "addr" ); 146 QCString addrStr = args->getOption( "addr" );
150 QCString uidStr = args->getOption( "uid" ); 147 QCString uidStr = args->getOption( "uid" );
151 QString addr; 148 QString addr;
152 QString uid; 149 QString uid;
153 if ( !addrStr.isEmpty() ) 150 if ( !addrStr.isEmpty() )
154 addr = QString::fromLocal8Bit( addrStr ); 151 addr = QString::fromLocal8Bit( addrStr );
155 if ( !uidStr.isEmpty() ) 152 if ( !uidStr.isEmpty() )
156 uid = QString::fromLocal8Bit( uidStr ); 153 uid = QString::fromLocal8Bit( uidStr );
157 154
158 155
159 if ( args->isSet( "editor-only" ) ) { 156 if ( args->isSet( "editor-only" ) ) {
160 if ( !mMainWin ) 157 if ( !mMainWin )
161 mMainWin = new KAddressBookMain; 158 mMainWin = new KAddressBookMain;
162 KStartupInfo::appStarted(); 159 KStartupInfo::appStarted();
163 mMainWin->hide(); 160 mMainWin->hide();
164 } else { 161 } else {
165 if ( mMainWin ) { 162 if ( mMainWin ) {
166 mMainWin->show(); 163 mMainWin->show();
167 KWin::setActiveWindow( mMainWin->winId() ); 164 KWin::setActiveWindow( mMainWin->winId() );
168 } else { 165 } else {
169 mMainWin = new KAddressBookMain; 166 mMainWin = new KAddressBookMain;
170 mMainWin->show(); 167 mMainWin->show();
171 } 168 }
172 } 169 }
173 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 170 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
174 if ( !addr.isEmpty() ) 171 if ( !addr.isEmpty() )
175 mMainWin->addEmail( addr ); 172 mMainWin->addEmail( addr );
176 173
177 if ( !uid.isEmpty() ) 174 if ( !uid.isEmpty() )
178 mMainWin->showContactEditor( uid ); 175 mMainWin->showContactEditor( uid );
179 if ( args->isSet( "new-contact" ) ) { 176 if ( args->isSet( "new-contact" ) ) {
180 mMainWin->newContact(); 177 mMainWin->newContact();
181 } 178 }
182 } 179 }
183 180
184 KCrash::setEmergencySaveFunction( crashHandler ); 181 KCrash::setEmergencySaveFunction( crashHandler );
185 182
186 return 0; 183 return 0;
187} 184}
188 185
189// the dummy argument is required, because KMail apparently sends an empty 186// the dummy argument is required, because KMail apparently sends an empty
190// argument. 187// argument.
191static KCmdLineOptions kmoptions[] = 188static KCmdLineOptions kmoptions[] =
192{ 189{
193 { "a", 0 , 0 }, 190 { "a", 0 , 0 },
194 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 191 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
195 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 192 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
196 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 193 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
197 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 194 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
198 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 195 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
199 { 0, 0, 0} 196 { 0, 0, 0}
200}; 197};
201 198
202int main( int argc, char *argv[] ) 199int main( int argc, char *argv[] )
203{ 200{
204 KLocale::setMainCatalogue( "kaddressbook" ); 201 KLocale::setMainCatalogue( "kaddressbook" );
205 202
206 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 203 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
207 KCmdLineArgs::addCmdLineOptions( kmoptions ); 204 KCmdLineArgs::addCmdLineOptions( kmoptions );
208 KUniqueApplication::addCmdLineOptions(); 205 KUniqueApplication::addCmdLineOptions();
209 206
210 if ( !KAddressBookApp::start() ) 207 if ( !KAddressBookApp::start() )
211 exit( 0 ); 208 exit( 0 );
212 209
213 KAddressBookApp app; 210 KAddressBookApp app;
214 KGlobal::locale()->insertCatalogue( "libkdepim" ); 211 KGlobal::locale()->insertCatalogue( "libkdepim" );
215 212
216 return app.exec(); 213 return app.exec();
217} 214}
218*/ 215*/