Diffstat (limited to 'kaddressbook/mainembedded.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/mainembedded.cpp | 8 |
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,150 +1,156 @@ | |||
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 | ||
20 | int main( int argc, char **argv ) | 21 | int 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 | ||
110 | extern "C" { | 116 | extern "C" { |
111 | 117 | ||
112 | void crashHandler( int ) | 118 | void 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 | ||
120 | class KAddressBookApp : public KUniqueApplication { | 126 | class 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 | ||
131 | int KAddressBookApp::newInstance() | 137 | int 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 ); |