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