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