author | zecke <zecke> | 2002-10-16 15:34:05 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-16 15:34:05 (UTC) |
commit | 321cea04e34658fde3de47c104682b5cefce6eeb (patch) (unidiff) | |
tree | abdf45ae54d24dedfd20e4e40371df5f39687139 /x11 | |
parent | 61f2f6ef32685002710f197dc8990fd9e99d83a5 (diff) | |
download | opie-321cea04e34658fde3de47c104682b5cefce6eeb.zip opie-321cea04e34658fde3de47c104682b5cefce6eeb.tar.gz opie-321cea04e34658fde3de47c104682b5cefce6eeb.tar.bz2 |
more implementation!!
OCOPClient now tries to start the server
-rw-r--r-- | x11/ipc/client/ocopclient.cpp | 21 | ||||
-rw-r--r-- | x11/ipc/client/ocopclient.h | 4 | ||||
-rw-r--r-- | x11/libqpe-x11/qpe/qpeapplication.cpp | 207 | ||||
-rw-r--r-- | x11/libqpe-x11/qpe/qpeapplication.h | 23 |
4 files changed, 241 insertions, 14 deletions
diff --git a/x11/ipc/client/ocopclient.cpp b/x11/ipc/client/ocopclient.cpp index 43e426c..ac6e4a3 100644 --- a/x11/ipc/client/ocopclient.cpp +++ b/x11/ipc/client/ocopclient.cpp | |||
@@ -1,129 +1,150 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <sys/socket.h> | 5 | #include <sys/socket.h> |
6 | #include <sys/types.h> | ||
6 | #include <sys/un.h> | 7 | #include <sys/un.h> |
7 | 8 | ||
8 | 9 | ||
9 | #include <qfile.h> | 10 | #include <qfile.h> |
10 | #include <qtimer.h> | 11 | #include <qtimer.h> |
11 | 12 | ||
12 | #include "../common/ocoppacket.h" | 13 | #include "../common/ocoppacket.h" |
13 | 14 | ||
14 | #include "ocopclient.h" | 15 | #include "ocopclient.h" |
15 | 16 | ||
16 | OCOPClient::OCOPClient( const QString& path, QObject* obj ) | 17 | OCOPClient::OCOPClient( const QString& path, QObject* obj ) |
17 | : QObject( obj ) | 18 | : QObject( obj ) |
18 | { | 19 | { |
20 | m_tries = 0; | ||
19 | init(QFile::encodeName(path) ); | 21 | init(QFile::encodeName(path) ); |
20 | } | 22 | } |
21 | OCOPClient::~OCOPClient() { | 23 | OCOPClient::~OCOPClient() { |
24 | delete m_notify; | ||
22 | close( m_socket ); | 25 | close( m_socket ); |
23 | } | 26 | } |
27 | void OCOPClient::init() { | ||
28 | // failed start ther server NOW!!! | ||
29 | startUP(); | ||
30 | QCString str; | ||
31 | init(str ); | ||
32 | } | ||
24 | void OCOPClient::init( const QCString& ) { | 33 | void OCOPClient::init( const QCString& ) { |
34 | m_tries++; | ||
25 | struct sockaddr_un unix_adr; | 35 | struct sockaddr_un unix_adr; |
26 | if ( (m_socket = socket(PF_UNIX, SOCK_STREAM, 0) ) < 0 ) { | 36 | if ( (m_socket = socket(PF_UNIX, SOCK_STREAM, 0) ) < 0 ) { |
27 | qWarning("could not socket"); | 37 | qWarning("could not socket"); |
38 | if ( m_tries < 8 ) | ||
28 | QTimer::singleShot(400, this,SLOT(init() ) ); | 39 | QTimer::singleShot(400, this,SLOT(init() ) ); |
29 | return; | 40 | return; |
30 | } | 41 | } |
31 | memset(&unix_adr, 0, sizeof(unix_adr ) ); | 42 | memset(&unix_adr, 0, sizeof(unix_adr ) ); |
32 | unix_adr.sun_family = AF_UNIX; | 43 | unix_adr.sun_family = AF_UNIX; |
33 | sprintf(unix_adr.sun_path,"%s/.opie.cop", getenv("HOME") ); | 44 | sprintf(unix_adr.sun_path,"%s/.opie.cop", getenv("HOME") ); |
34 | int length = sizeof(unix_adr.sun_family) + strlen(unix_adr.sun_path); | 45 | int length = sizeof(unix_adr.sun_family) + strlen(unix_adr.sun_path); |
35 | 46 | ||
36 | if ( ::connect(m_socket, (struct sockaddr*)&unix_adr, length ) < 0 ) { | 47 | if ( ::connect(m_socket, (struct sockaddr*)&unix_adr, length ) < 0 ) { |
37 | qWarning("could not connect %d", errno ); | 48 | qWarning("could not connect %d", errno ); |
38 | close( m_socket ); | 49 | close( m_socket ); |
50 | if ( m_tries < 8 ) | ||
39 | QTimer::singleShot(400, this, SLOT(init() ) ); | 51 | QTimer::singleShot(400, this, SLOT(init() ) ); |
40 | return; | 52 | return; |
41 | } | 53 | } |
42 | m_notify = new QSocketNotifier(m_socket, QSocketNotifier::Read, this ); | 54 | m_notify = new QSocketNotifier(m_socket, QSocketNotifier::Read, this ); |
43 | connect( m_notify, SIGNAL(activated(int) ), | 55 | connect( m_notify, SIGNAL(activated(int) ), |
44 | this, SLOT(newData() ) ); | 56 | this, SLOT(newData() ) ); |
45 | } | 57 | } |
46 | /** | 58 | /** |
47 | * new data | 59 | * new data |
48 | * read the header check magic number | 60 | * read the header check magic number |
49 | * and maybe read body | 61 | * and maybe read body |
50 | */ | 62 | */ |
51 | void OCOPClient::newData() { | 63 | void OCOPClient::newData() { |
52 | OCOPPacket pack = packet(); | 64 | OCOPPacket pack = packet(); |
53 | if ( pack.channel().isEmpty() ) | 65 | if ( pack.channel().isEmpty() ) |
54 | return; | 66 | return; |
55 | 67 | ||
56 | switch( pack.type() ) { | 68 | switch( pack.type() ) { |
57 | case OCOPPacket::Register: | 69 | case OCOPPacket::Register: |
58 | case OCOPPacket::Unregister: | 70 | case OCOPPacket::Unregister: |
59 | case OCOPPacket::Method: | 71 | case OCOPPacket::Method: |
60 | case OCOPPacket::RegisterChannel: | 72 | case OCOPPacket::RegisterChannel: |
61 | case OCOPPacket::UnregisterChannel: | 73 | case OCOPPacket::UnregisterChannel: |
62 | case OCOPPacket::Return: | 74 | case OCOPPacket::Return: |
63 | case OCOPPacket::Signal: | 75 | case OCOPPacket::Signal: |
64 | /* is Registered should be handled sync */ | 76 | /* is Registered should be handled sync */ |
65 | case OCOPPacket::IsRegistered: | 77 | case OCOPPacket::IsRegistered: |
66 | break; | 78 | break; |
67 | /* emit the signal */ | 79 | /* emit the signal */ |
68 | case OCOPPacket::Call: | 80 | case OCOPPacket::Call: |
69 | emit called( pack.channel(), pack.header(), pack.content() ); | 81 | emit called( pack.channel(), pack.header(), pack.content() ); |
70 | break; | 82 | break; |
71 | } | 83 | } |
72 | } | 84 | } |
73 | OCOPPacket OCOPClient::packet() const{ | 85 | OCOPPacket OCOPClient::packet() const{ |
74 | QCString chan; | 86 | QCString chan; |
75 | QCString func; | 87 | QCString func; |
76 | QByteArray ar; | 88 | QByteArray ar; |
77 | OCOPHead head; | 89 | OCOPHead head; |
78 | memset(&head, 0, sizeof(head) ); | 90 | memset(&head, 0, sizeof(head) ); |
79 | read(m_socket, &head, sizeof(head) ); | 91 | read(m_socket, &head, sizeof(head) ); |
80 | if ( head.magic == 47 ) { | 92 | if ( head.magic == 47 ) { |
81 | read(m_socket, chan.data(), head.chlen ); | 93 | read(m_socket, chan.data(), head.chlen ); |
82 | read(m_socket, func.data(), head.funclen ); | 94 | read(m_socket, func.data(), head.funclen ); |
83 | read(m_socket, ar.data(), head.datalen ); | 95 | read(m_socket, ar.data(), head.datalen ); |
84 | } | 96 | } |
85 | OCOPPacket pack(head.type, chan, func, ar ); | 97 | OCOPPacket pack(head.type, chan, func, ar ); |
86 | return pack; | 98 | return pack; |
87 | } | 99 | } |
88 | /* | 100 | /* |
89 | * we've blocking IO here on these sockets | 101 | * we've blocking IO here on these sockets |
90 | * so we send and go on read | 102 | * so we send and go on read |
91 | * this will be blocked | 103 | * this will be blocked |
92 | */ | 104 | */ |
93 | bool OCOPClient::isRegistered( const QCString& chan ) const{ | 105 | bool OCOPClient::isRegistered( const QCString& chan ) const{ |
94 | /* should I disconnect the socket notfier? */ | 106 | /* should I disconnect the socket notfier? */ |
95 | OCOPPacket packe(OCOPPacket::IsRegistered, chan ); | 107 | OCOPPacket packe(OCOPPacket::IsRegistered, chan ); |
96 | OCOPHead head = packe.head(); | 108 | OCOPHead head = packe.head(); |
97 | write(m_socket, &head, sizeof(head) ); | 109 | write(m_socket, &head, sizeof(head) ); |
98 | 110 | ||
99 | /* block */ | 111 | /* block */ |
100 | OCOPPacket pack = packet(); | 112 | OCOPPacket pack = packet(); |
101 | 113 | ||
102 | /* connect here again */ | 114 | /* connect here again */ |
103 | if ( pack.channel() == chan ) { | 115 | if ( pack.channel() == chan ) { |
104 | QCString func = pack.header(); | 116 | QCString func = pack.header(); |
105 | if (func[0] == 1 ) | 117 | if (func[0] == 1 ) |
106 | return true; | 118 | return true; |
107 | } | 119 | } |
108 | 120 | ||
109 | return false; | 121 | return false; |
110 | }; | 122 | }; |
111 | void OCOPClient::send( const QCString& chan, const QCString& fu, const QByteArray& arr ) { | 123 | void OCOPClient::send( const QCString& chan, const QCString& fu, const QByteArray& arr ) { |
112 | OCOPPacket pack(OCOPPacket::Call, chan, fu, arr ); | 124 | OCOPPacket pack(OCOPPacket::Call, chan, fu, arr ); |
113 | call( pack ); | 125 | call( pack ); |
114 | } | 126 | } |
115 | void OCOPClient::addChannel(const QCString& channel) { | 127 | void OCOPClient::addChannel(const QCString& channel) { |
116 | OCOPPacket pack(OCOPPacket::RegisterChannel, channel ); | 128 | OCOPPacket pack(OCOPPacket::RegisterChannel, channel ); |
117 | call( pack ); | 129 | call( pack ); |
118 | } | 130 | } |
119 | void OCOPClient::delChannel(const QCString& chan ) { | 131 | void OCOPClient::delChannel(const QCString& chan ) { |
120 | OCOPPacket pack(OCOPPacket::UnregisterChannel, chan ); | 132 | OCOPPacket pack(OCOPPacket::UnregisterChannel, chan ); |
121 | call( pack ); | 133 | call( pack ); |
122 | } | 134 | } |
123 | void OCOPClient::call( const OCOPPacket& pack ) { | 135 | void OCOPClient::call( const OCOPPacket& pack ) { |
124 | OCOPHead head = pack.head(); | 136 | OCOPHead head = pack.head(); |
125 | write(m_socket, &head, sizeof(head) ); | 137 | write(m_socket, &head, sizeof(head) ); |
126 | write(m_socket, pack.channel().data(), pack.channel().size() ); | 138 | write(m_socket, pack.channel().data(), pack.channel().size() ); |
127 | write(m_socket, pack.header().data(), pack.header().size() ); | 139 | write(m_socket, pack.header().data(), pack.header().size() ); |
128 | write(m_socket, pack.content().data(), pack.content().size() ); | 140 | write(m_socket, pack.content().data(), pack.content().size() ); |
129 | } | 141 | } |
142 | void OCOPClient::startUP() { | ||
143 | qWarning("Start me up"); | ||
144 | pid_t pi = fork(); | ||
145 | if ( pi == 0 ) { | ||
146 | setsid(); | ||
147 | execlp("opie-ipc", "opie-ipc", NULL ); | ||
148 | _exit(1); | ||
149 | } | ||
150 | } | ||
diff --git a/x11/ipc/client/ocopclient.h b/x11/ipc/client/ocopclient.h index e9544b9..53018a5 100644 --- a/x11/ipc/client/ocopclient.h +++ b/x11/ipc/client/ocopclient.h | |||
@@ -1,59 +1,61 @@ | |||
1 | #ifndef OPIE_OCOP_CLIENT_H | 1 | #ifndef OPIE_OCOP_CLIENT_H |
2 | #define OPIE_OCOP_CLIENT_H | 2 | #define OPIE_OCOP_CLIENT_H |
3 | 3 | ||
4 | 4 | ||
5 | #include <qobject.h> | 5 | #include <qobject.h> |
6 | #include <qcstring.h> | 6 | #include <qcstring.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qsignal.h> | 8 | #include <qsignal.h> |
9 | #include <qstring.h> | 9 | #include <qstring.h> |
10 | #include <qsocketnotifier.h> | 10 | #include <qsocketnotifier.h> |
11 | 11 | ||
12 | 12 | ||
13 | /** | 13 | /** |
14 | * This is the OCOP client | 14 | * This is the OCOP client |
15 | * It currently only supports | 15 | * It currently only supports |
16 | * asking if a Channel is registered, | 16 | * asking if a Channel is registered, |
17 | * calling and receiving calls | 17 | * calling and receiving calls |
18 | */ | 18 | */ |
19 | class OCOPPacket; | 19 | class OCOPPacket; |
20 | class OCOPClient : public QObject{ | 20 | class OCOPClient : public QObject{ |
21 | Q_OBJECT | 21 | Q_OBJECT |
22 | public: | 22 | public: |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * Occasionally I decide to start a Server from here | 25 | * Occasionally I decide to start a Server from here |
26 | */ | 26 | */ |
27 | OCOPClient(const QString& pathToServer = QString::null, QObject* obj = 0l); | 27 | OCOPClient(const QString& pathToServer = QString::null, QObject* obj = 0l); |
28 | ~OCOPClient(); | 28 | ~OCOPClient(); |
29 | 29 | ||
30 | bool isRegistered( const QCString& )const; | 30 | bool isRegistered( const QCString& )const; |
31 | void send( const QCString& chan, const QCString&, const QByteArray& msg ); | 31 | void send( const QCString& chan, const QCString&, const QByteArray& msg ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * add a channel and does connect to a signal | 34 | * add a channel and does connect to a signal |
35 | * callback is the object | 35 | * callback is the object |
36 | * slot is the SLOT() | 36 | * slot is the SLOT() |
37 | */ | 37 | */ |
38 | void addChannel( const QCString& channel ); | 38 | void addChannel( const QCString& channel ); |
39 | void delChannel( const QCString& channel ); | 39 | void delChannel( const QCString& channel ); |
40 | 40 | ||
41 | /* make it singleton? */ | 41 | /* make it singleton? */ |
42 | //static OCOPClient* self(); | 42 | //static OCOPClient* self(); |
43 | /* no direct signals due the design */ | 43 | /* no direct signals due the design */ |
44 | signals: | 44 | signals: |
45 | void called(const QCString&, const QCString&, const QByteArray& ); | 45 | void called(const QCString&, const QCString&, const QByteArray& ); |
46 | private slots: | 46 | private slots: |
47 | void init(); | ||
47 | void init(const QCString& pa); | 48 | void init(const QCString& pa); |
48 | void newData(); | 49 | void newData(); |
49 | private: | 50 | private: |
51 | void startUP(); | ||
50 | OCOPPacket packet()const; | 52 | OCOPPacket packet()const; |
51 | void call( const OCOPPacket& ); | 53 | void call( const OCOPPacket& ); |
52 | 54 | ||
53 | QSocketNotifier* m_notify; | 55 | QSocketNotifier* m_notify; |
54 | int m_socket; | 56 | int m_socket; |
55 | private slots: | 57 | int m_tries; |
56 | 58 | ||
57 | }; | 59 | }; |
58 | 60 | ||
59 | #endif | 61 | #endif |
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp index 891e132..6e4a96c 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.cpp +++ b/x11/libqpe-x11/qpe/qpeapplication.cpp | |||
@@ -158,334 +158,515 @@ void QPEApplication::Private::loadImageCodecs() { | |||
158 | // ### it exists now; need to remember if we can delete it | 158 | // ### it exists now; need to remember if we can delete it |
159 | } | 159 | } |
160 | } | 160 | } |
161 | else { | 161 | else { |
162 | lib->unload(); | 162 | lib->unload(); |
163 | delete lib; | 163 | delete lib; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | // The Help System hook | 168 | // The Help System hook |
169 | namespace { | 169 | namespace { |
170 | class ResourceMimeFactory : public QMimeSourceFactory | 170 | class ResourceMimeFactory : public QMimeSourceFactory |
171 | { | 171 | { |
172 | public: | 172 | public: |
173 | ResourceMimeFactory(); | 173 | ResourceMimeFactory(); |
174 | ~ResourceMimeFactory(); | 174 | ~ResourceMimeFactory(); |
175 | const QMimeSource* data( const QString& abs_name )const; | 175 | const QMimeSource* data( const QString& abs_name )const; |
176 | }; | 176 | }; |
177 | ResourceMimeFactory::ResourceMimeFactory() | 177 | ResourceMimeFactory::ResourceMimeFactory() |
178 | { | 178 | { |
179 | setFilePath( Global::helpPath() ); | 179 | setFilePath( Global::helpPath() ); |
180 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 180 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
181 | } | 181 | } |
182 | ResourceMimeFactory::~ResourceMimeFactory() { | 182 | ResourceMimeFactory::~ResourceMimeFactory() { |
183 | } | 183 | } |
184 | 184 | ||
185 | const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const | 185 | const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const |
186 | { | 186 | { |
187 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 187 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
188 | if ( !r ) { | 188 | if ( !r ) { |
189 | int sl = abs_name.length(); | 189 | int sl = abs_name.length(); |
190 | do { | 190 | do { |
191 | sl = abs_name.findRev( '/', sl - 1 ); | 191 | sl = abs_name.findRev( '/', sl - 1 ); |
192 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 192 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
193 | int dot = name.findRev( '.' ); | 193 | int dot = name.findRev( '.' ); |
194 | if ( dot >= 0 ) | 194 | if ( dot >= 0 ) |
195 | name = name.left( dot ); | 195 | name = name.left( dot ); |
196 | QImage img = Resource::loadImage( name ); | 196 | QImage img = Resource::loadImage( name ); |
197 | if ( !img.isNull() ) | 197 | if ( !img.isNull() ) |
198 | r = new QImageDrag( img ); | 198 | r = new QImageDrag( img ); |
199 | } | 199 | } |
200 | while ( !r && sl > 0 ); | 200 | while ( !r && sl > 0 ); |
201 | } | 201 | } |
202 | return r; | 202 | return r; |
203 | }; | 203 | }; |
204 | }; | 204 | }; |
205 | // QPEApplication | 205 | // QPEApplication |
206 | QPEApplication::~QPEApplication() { | ||
207 | qWarning("~QPEApplication"); | ||
208 | ungrabKeyboard(); | ||
209 | qWarning("UngrabKeyboard"); | ||
210 | |||
211 | // delete m_sys; | ||
212 | // delete m_pid; | ||
213 | |||
214 | delete d; | ||
215 | } | ||
206 | QPEApplication::QPEApplication(int &arg, char** argv, Type t) | 216 | QPEApplication::QPEApplication(int &arg, char** argv, Type t) |
207 | : QApplication( arg, argv, t ) { | 217 | : QApplication( arg, argv, t ) { |
208 | d = new Private; | 218 | d = new Private; |
209 | d->loadTextCodecs(); | 219 | d->loadTextCodecs(); |
210 | d->loadImageCodecs(); | 220 | d->loadImageCodecs(); |
211 | 221 | ||
212 | int dw = desktop()->width(); | 222 | int dw = desktop()->width(); |
213 | if ( dw < 200 ) { | 223 | if ( dw < 200 ) { |
214 | setFont( QFont( "helvetica", 8 ) ); | 224 | setFont( QFont( "helvetica", 8 ) ); |
215 | AppLnk::setSmallIconSize( 10 ); | 225 | AppLnk::setSmallIconSize( 10 ); |
216 | AppLnk::setBigIconSize( 28 ); | 226 | AppLnk::setBigIconSize( 28 ); |
217 | }else if ( dw > 600 ) { | 227 | }else if ( dw > 600 ) { |
218 | setFont( QFont( "helvetica", 12 ) ); | 228 | setFont( QFont( "helvetica", 12 ) ); |
219 | AppLnk::setSmallIconSize( 24 ); | 229 | AppLnk::setSmallIconSize( 24 ); |
220 | AppLnk::setBigIconSize( 48 ); | 230 | AppLnk::setBigIconSize( 48 ); |
221 | }else if ( dw > 200 ) { | 231 | }else if ( dw > 200 ) { |
222 | setFont( QFont( "helvetica", 10 ) ); | 232 | setFont( QFont( "helvetica", 10 ) ); |
223 | AppLnk::setSmallIconSize( 16 ); | 233 | AppLnk::setSmallIconSize( 16 ); |
224 | AppLnk::setBigIconSize( 32 ); | 234 | AppLnk::setBigIconSize( 32 ); |
225 | } | 235 | } |
226 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 236 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
227 | 237 | ||
228 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) ); | 238 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) ); |
229 | 239 | ||
230 | QString qcopfn( "/tmp/qcop-msg-" ); | 240 | QString qcopfn( "/tmp/qcop-msg-" ); |
231 | qcopfn += QString( argv[0] ); // append command name to the QCOP name | 241 | qcopfn += QString( argv[0] ); // append command name to the QCOP name |
232 | QFile file( qcopfn ); | 242 | QFile file( qcopfn ); |
233 | if (file.open(IO_ReadOnly ) ) { | 243 | if (file.open(IO_ReadOnly ) ) { |
234 | flock( file.handle(), LOCK_EX ); | 244 | flock( file.handle(), LOCK_EX ); |
235 | } | 245 | } |
236 | 246 | ||
237 | m_sys = new QCopChannel( "QPE/System", this ); | 247 | /* Hmmm damn we need to make the parent 0l otherwise it get's deleted |
248 | * past the QApplication | ||
249 | */ | ||
250 | m_sys = new QCopChannel( "QPE/System", 0l); | ||
238 | connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ), | 251 | connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ), |
239 | this, SLOT(systemMessage( const QCString&, const QByteArray& ) ) ); | 252 | this, SLOT(systemMessage( const QCString&, const QByteArray& ) ) ); |
240 | 253 | ||
241 | // private channel QPE/Application/appname | 254 | // private channel QPE/Application/appname |
242 | QCString channel = QCString( argv[0] ); | 255 | QCString channel = QCString( argv[0] ); |
243 | channel.replace( QRegExp( ".*/"), "" ); | 256 | channel.replace( QRegExp( ".*/"), "" ); |
244 | d->appName = channel; | 257 | d->appName = channel; |
245 | channel = "QPE/Application/"+ channel; | 258 | channel = "QPE/Application/"+ channel; |
246 | m_pid = new QCopChannel( channel, this ); | 259 | m_pid = new QCopChannel( channel, 0l ); |
247 | connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ), | 260 | connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ), |
248 | this, SLOT( pidMessage( const QCString&, const QByteArray& ) ) ); | 261 | this, SLOT( pidMessage( const QCString&, const QByteArray& ) ) ); |
249 | 262 | ||
250 | // read the Pre QCOP Stuff from the file | 263 | // read the Pre QCOP Stuff from the file |
251 | if ( file.isOpen() ) { | 264 | if ( file.isOpen() ) { |
252 | d->keep_running = FALSE; | 265 | d->keep_running = FALSE; |
253 | QDataStream ds( &file ); | 266 | QDataStream ds( &file ); |
254 | QCString chanel, message; | 267 | QCString chanel, message; |
255 | QByteArray data; | 268 | QByteArray data; |
256 | while (!ds.atEnd() ) { | 269 | while (!ds.atEnd() ) { |
257 | ds >> chanel >> message >> data; | 270 | ds >> chanel >> message >> data; |
258 | d->enqueueQCop( chanel, message, data ); | 271 | d->enqueueQCop( chanel, message, data ); |
259 | } | 272 | } |
260 | flock( file.handle(), LOCK_UN ); | 273 | flock( file.handle(), LOCK_UN ); |
261 | file.close(); | 274 | file.close(); |
262 | file.remove(); | 275 | file.remove(); |
263 | } | 276 | } |
264 | 277 | ||
265 | // read in some stuff from the command line | 278 | // read in some stuff from the command line |
266 | // we do not have setArgs so we need to take | 279 | // we do not have setArgs so we need to take |
267 | // care of that | 280 | // care of that |
268 | for ( int a = 0; a < arg; a++ ) { | 281 | for ( int a = 0; a < arg; a++ ) { |
269 | if ( qstrcmp( argv[a], "-preload" ) == 0 ) { | 282 | if ( qstrcmp( argv[a], "-preload" ) == 0 ) { |
270 | d->preloaded = TRUE; | 283 | d->preloaded = TRUE; |
271 | }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) { | 284 | }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) { |
272 | d->preloaded = TRUE; | 285 | d->preloaded = TRUE; |
273 | d->forceshow = TRUE; | 286 | d->forceshow = TRUE; |
274 | } | 287 | } |
275 | } | 288 | } |
276 | initTranslations(); | 289 | initTranslations(); |
277 | applyStyle(); | 290 | applyStyle(); |
278 | 291 | ||
279 | if ( type() == GuiServer ) | 292 | if ( type() == GuiServer ) |
280 | ; | 293 | ; |
281 | 294 | ||
282 | installEventFilter( this ); | 295 | installEventFilter( this ); |
283 | QPEMenuToolFocusManager::initialize(); | 296 | QPEMenuToolFocusManager::initialize(); |
284 | } | 297 | } |
285 | void QPEApplication::initTranslations() { | 298 | void QPEApplication::initTranslations() { |
286 | // Translations add it | 299 | // Translations add it |
287 | QStringList langs = Global::languageList(); | 300 | QStringList langs = Global::languageList(); |
288 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 301 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
289 | QString lang = *it; | 302 | QString lang = *it; |
290 | 303 | ||
291 | QTranslator * trans; | 304 | QTranslator * trans; |
292 | QString tfn; | 305 | QString tfn; |
293 | 306 | ||
294 | trans = new QTranslator( this ); | 307 | trans = new QTranslator( this ); |
295 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 308 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
296 | if ( trans->load( tfn ) ) | 309 | if ( trans->load( tfn ) ) |
297 | installTranslator( trans ); | 310 | installTranslator( trans ); |
298 | else | 311 | else |
299 | delete trans; | 312 | delete trans; |
300 | 313 | ||
301 | trans = new QTranslator( this ); | 314 | trans = new QTranslator( this ); |
302 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 315 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
303 | if ( trans->load( tfn ) ) | 316 | if ( trans->load( tfn ) ) |
304 | installTranslator( trans ); | 317 | installTranslator( trans ); |
305 | else | 318 | else |
306 | delete trans; | 319 | delete trans; |
307 | } | 320 | } |
308 | } | 321 | } |
309 | QPEApplication::~QPEApplication() { | ||
310 | delete d; | ||
311 | } | ||
312 | QString QPEApplication::qpeDir() { | 322 | QString QPEApplication::qpeDir() { |
313 | const char * base = getenv( "OPIEDIR" ); | 323 | const char * base = getenv( "OPIEDIR" ); |
314 | if ( base ) | 324 | if ( base ) |
315 | return QString( base ) + "/"; | 325 | return QString( base ) + "/"; |
316 | 326 | ||
317 | return QString( "../" ); | 327 | return QString( "../" ); |
318 | } | 328 | } |
319 | QString QPEApplication::documentDir() { | 329 | QString QPEApplication::documentDir() { |
320 | const char* base = getenv( "HOME"); | 330 | const char* base = getenv( "HOME"); |
321 | if ( base ) | 331 | if ( base ) |
322 | return QString( base ) + "/Documents"; | 332 | return QString( base ) + "/Documents"; |
323 | 333 | ||
324 | return QString( "../Documents" ); | 334 | return QString( "../Documents" ); |
325 | } | 335 | } |
326 | void QPEApplication::applyStyle() { | 336 | void QPEApplication::applyStyle() { |
327 | Config config( "qpe" ); | 337 | Config config( "qpe" ); |
328 | 338 | ||
329 | config.setGroup( "Appearance" ); | 339 | config.setGroup( "Appearance" ); |
330 | 340 | ||
331 | // Widget style | 341 | // Widget style |
332 | QString style = config.readEntry( "Style", "Light" ); | 342 | QString style = config.readEntry( "Style", "Light" ); |
333 | internalSetStyle( style ); | 343 | internalSetStyle( style ); |
334 | 344 | ||
335 | // Colors | 345 | // Colors |
336 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 346 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
337 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 347 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
338 | QPalette pal( btncolor, bgcolor ); | 348 | QPalette pal( btncolor, bgcolor ); |
339 | QString color = config.readEntry( "Highlight", "#800000" ); | 349 | QString color = config.readEntry( "Highlight", "#800000" ); |
340 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 350 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
341 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 351 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
342 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 352 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
343 | color = config.readEntry( "Text", "#000000" ); | 353 | color = config.readEntry( "Text", "#000000" ); |
344 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 354 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
345 | color = config.readEntry( "ButtonText", "#000000" ); | 355 | color = config.readEntry( "ButtonText", "#000000" ); |
346 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 356 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
347 | color = config.readEntry( "Base", "#FFFFFF" ); | 357 | color = config.readEntry( "Base", "#FFFFFF" ); |
348 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 358 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
349 | 359 | ||
350 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 360 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
351 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 361 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
352 | 362 | ||
353 | setPalette( pal, TRUE ); | 363 | setPalette( pal, TRUE ); |
354 | 364 | ||
355 | 365 | ||
356 | 366 | ||
357 | // Font | 367 | // Font |
358 | QString ff = config.readEntry( "FontFamily", font().family() ); | 368 | QString ff = config.readEntry( "FontFamily", font().family() ); |
359 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 369 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
360 | setFont( QFont(ff, fs) ); | 370 | setFont( QFont(ff, fs) ); |
361 | } | 371 | } |
362 | int QPEApplication::defaultRotation() { | 372 | int QPEApplication::defaultRotation() { |
363 | return 0; | 373 | return 0; |
364 | } | 374 | } |
365 | void QPEApplication::setDefaultRotation(int r ) { | 375 | void QPEApplication::setDefaultRotation(int r ) { |
366 | 376 | ||
367 | } | 377 | } |
368 | void QPEApplication::grabKeyboard() { | 378 | void QPEApplication::grabKeyboard() { |
369 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; | 379 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; |
370 | if ( qApp->type() == QApplication::GuiServer ) | 380 | if ( qApp->type() == QApplication::GuiServer ) |
371 | d->kbgrabber = 0; | 381 | d->kbgrabber = 0; |
372 | else { | 382 | else { |
373 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 383 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
374 | e << d->appName; | 384 | e << d->appName; |
375 | 385 | ||
376 | d->kbgrabber = 2; // me | 386 | d->kbgrabber = 2; // me |
377 | } | 387 | } |
378 | } | 388 | } |
379 | void QPEApplication::ungrabKeyboard() { | 389 | void QPEApplication::ungrabKeyboard() { |
380 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; | 390 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; |
381 | if ( d->kbgrabber == 2 ) { | 391 | if ( d->kbgrabber == 2 ) { |
382 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 392 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
383 | e << QString::null; | 393 | e << QString::null; |
384 | 394 | ||
385 | d->kbregrab = FALSE; | 395 | d->kbregrab = FALSE; |
386 | d->kbgrabber = 0; | 396 | d->kbgrabber = 0; |
387 | } | 397 | } |
388 | } | 398 | } |
389 | void QPEApplication::setStylusOperation( QWidget*, StylusMode ) { | ||
390 | |||
391 | } | ||
392 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* ) { | ||
393 | |||
394 | } | ||
395 | void QPEApplication::showMainWidget( QWidget* wid, bool b) { | 399 | void QPEApplication::showMainWidget( QWidget* wid, bool b) { |
396 | d->show(wid, b ); | 400 | d->show(wid, b ); |
397 | } | 401 | } |
398 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) { | 402 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) { |
399 | if ( mw && argc() == 2 ) | 403 | if ( mw && argc() == 2 ) |
400 | Global::setDocument( mw, QString::fromUtf8(argv()[1] ) ); | 404 | Global::setDocument( mw, QString::fromUtf8(argv()[1] ) ); |
401 | 405 | ||
402 | d->show(mw, m ); | 406 | d->show(mw, m ); |
403 | } | 407 | } |
404 | void QPEApplication::showDialog( QDialog* d, bool nomax ) { | 408 | void QPEApplication::showDialog( QDialog* d, bool nomax ) { |
405 | QSize sh = d->sizeHint(); | 409 | QSize sh = d->sizeHint(); |
406 | int w = QMAX(sh.width(),d->width()); | 410 | int w = QMAX(sh.width(),d->width()); |
407 | int h = QMAX(sh.height(),d->height()); | 411 | int h = QMAX(sh.height(),d->height()); |
408 | if ( !nomax | 412 | if ( !nomax |
409 | && ( w > qApp->desktop()->width()*3/4 | 413 | && ( w > qApp->desktop()->width()*3/4 |
410 | || h > qApp->desktop()->height()*3/4 ) ) | 414 | || h > qApp->desktop()->height()*3/4 ) ) |
411 | { | 415 | { |
412 | d->showMaximized(); | 416 | d->showMaximized(); |
413 | } else { | 417 | } else { |
414 | d->resize(w,h); | 418 | d->resize(w,h); |
415 | d->show(); | 419 | d->show(); |
416 | } | 420 | } |
417 | } | 421 | } |
418 | int QPEApplication::execDialog( QDialog* d, bool nomax) { | 422 | int QPEApplication::execDialog( QDialog* d, bool nomax) { |
419 | showDialog(d,nomax); | 423 | showDialog(d,nomax); |
420 | return d->exec(); | 424 | return d->exec(); |
421 | } | 425 | } |
422 | void QPEApplication::setKeepRunning() { | 426 | void QPEApplication::setKeepRunning() { |
423 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 427 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
424 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 428 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
425 | qpeApp->d->keep_running = TRUE; | 429 | qpeApp->d->keep_running = TRUE; |
426 | } | 430 | } |
427 | } | 431 | } |
428 | bool QPEApplication::keepRunning()const { | 432 | bool QPEApplication::keepRunning()const { |
429 | return d->keep_running; | 433 | return d->keep_running; |
430 | } | 434 | } |
431 | bool QPEApplication::keyboardGrabbed()const { | 435 | bool QPEApplication::keyboardGrabbed()const { |
432 | return d->kbgrabber; | 436 | return d->kbgrabber; |
433 | } | 437 | } |
434 | int QPEApplication::exec() { | 438 | int QPEApplication::exec() { |
435 | /* now send the QCOP stuff gotten from the file */ | 439 | /* now send the QCOP stuff gotten from the file */ |
436 | d->sendQCopQ(); | 440 | d->sendQCopQ(); |
437 | 441 | ||
438 | if ( d->keep_running ) | 442 | if ( d->keep_running ) { |
439 | return QApplication::exec(); | 443 | qWarning("going to exec"); |
444 | int a = QApplication::exec(); | ||
445 | qWarning("left"); | ||
446 | return a; | ||
447 | } | ||
440 | 448 | ||
441 | { | 449 | { |
442 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 450 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
443 | e << d->appName; | 451 | e << d->appName; |
444 | } | 452 | } |
453 | qWarning("processing events!"); | ||
445 | processEvents(); | 454 | processEvents(); |
446 | return 0; | 455 | return 0; |
447 | } | 456 | } |
448 | void QPEApplication::internalSetStyle( const QString& ) { | 457 | void QPEApplication::internalSetStyle( const QString& ) { |
449 | 458 | ||
450 | } | 459 | } |
460 | void QPEApplication::systemMessage( const QCString&, const QByteArray& ) { | ||
461 | |||
462 | } | ||
463 | void QPEApplication::pidMessage( const QCString&, const QByteArray& ) { | ||
464 | |||
465 | } | ||
466 | void QPEApplication::timerEvent( QTimerEvent* e ) { | ||
467 | if ( e->timerId() == d->presstimer && d->presswidget ) { | ||
468 | // Right pressed | ||
469 | postEvent( d->presswidget, | ||
470 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | ||
471 | RightButton, LeftButton ) ); | ||
472 | killTimer( d->presstimer ); | ||
473 | d->presstimer = 0; | ||
474 | } | ||
475 | } | ||
476 | |||
477 | // InputMethods Hints | ||
478 | namespace { | ||
479 | static QPtrDict<void>* inputMethodDict = 0; | ||
480 | static void createInputMethodDict(){ | ||
481 | if ( !inputMethodDict ) | ||
482 | inputMethodDict = new QPtrDict<void>; | ||
483 | } | ||
484 | |||
485 | static QPtrDict<void>* stylusDict = 0; | ||
486 | static void createDict() { | ||
487 | if ( !stylusDict ) | ||
488 | stylusDict = new QPtrDict<void>; | ||
489 | } | ||
490 | }; | ||
491 | |||
492 | void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) { | ||
493 | createInputMethodDict(); | ||
494 | if ( mode == Normal ) { | ||
495 | inputMethodDict->remove | ||
496 | ( w ); | ||
497 | }else { | ||
498 | inputMethodDict->insert( w, ( void* ) mode ); | ||
499 | } | ||
500 | } | ||
501 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) { | ||
502 | if ( inputMethodDict && w ) | ||
503 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | ||
504 | return Normal; | ||
505 | } | ||
451 | 506 | ||
452 | 507 | ||
508 | void QPEApplication::removeSenderFromStylusDict() { | ||
509 | stylusDict->remove( ( void* ) sender() ); | ||
510 | if ( d->presswidget == sender() ) | ||
511 | d->presswidget = 0; | ||
512 | } | ||
513 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) { | ||
514 | createDict(); | ||
515 | if ( mode == LeftOnly ) { | ||
516 | stylusDict->remove | ||
517 | ( w ); | ||
518 | w->removeEventFilter( qApp ); | ||
519 | }else { | ||
520 | stylusDict->insert( w, ( void* ) mode ); | ||
521 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | ||
522 | w->installEventFilter( qApp ); | ||
523 | } | ||
524 | } | ||
525 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) { | ||
526 | if ( stylusDict ) | ||
527 | return ( StylusMode ) ( int ) stylusDict->find( w ); | ||
528 | return LeftOnly; | ||
529 | } | ||
530 | |||
531 | // eventFilter...... | ||
532 | bool QPEApplication::eventFilter( QObject* o, QEvent* e ) { | ||
533 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | ||
534 | QMouseEvent * me = ( QMouseEvent* ) e; | ||
535 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | ||
536 | switch (mode) { | ||
537 | case RightOnHold: | ||
538 | switch ( me->type() ) { | ||
539 | case QEvent::MouseButtonPress: | ||
540 | if ( me->button() == LeftButton ) { | ||
541 | d->presstimer = startTimer(500); // #### pref. | ||
542 | d->presswidget = (QWidget*)o; | ||
543 | d->presspos = me->pos(); | ||
544 | d->rightpressed = FALSE; | ||
545 | } | ||
546 | break; | ||
547 | case QEvent::MouseMove: | ||
548 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | ||
549 | killTimer(d->presstimer); | ||
550 | d->presstimer = 0; | ||
551 | } | ||
552 | break; | ||
553 | case QEvent::MouseButtonRelease: | ||
554 | if ( me->button() == LeftButton ) { | ||
555 | if ( d->presstimer ) { | ||
556 | killTimer(d->presstimer); | ||
557 | d->presstimer = 0; | ||
558 | } | ||
559 | if ( d->rightpressed && d->presswidget ) { | ||
560 | // Right released | ||
561 | postEvent( d->presswidget, | ||
562 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | ||
563 | RightButton, LeftButton + RightButton ) ); | ||
564 | // Left released, off-widget | ||
565 | postEvent( d->presswidget, | ||
566 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | ||
567 | LeftButton, LeftButton ) ); | ||
568 | postEvent( d->presswidget, | ||
569 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | ||
570 | LeftButton, LeftButton ) ); | ||
571 | d->rightpressed = FALSE; | ||
572 | return TRUE; // don't send the real Left release | ||
573 | } | ||
574 | } | ||
575 | break; | ||
576 | default: | ||
577 | break; | ||
578 | } | ||
579 | break; | ||
580 | default: | ||
581 | ; | ||
582 | } | ||
583 | } | ||
584 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
585 | QKeyEvent *ke = (QKeyEvent *)e; | ||
586 | if ( ke->key() == Key_Enter ) { | ||
587 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | ||
588 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | ||
589 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | ||
590 | return TRUE; | ||
591 | } | ||
592 | } | ||
593 | } | ||
594 | return FALSE; | ||
595 | } | ||
596 | |||
597 | // Quit stuff | ||
598 | void QPEApplication::restart() { | ||
599 | |||
600 | } | ||
601 | void QPEApplication::shutdown() { | ||
602 | |||
603 | } | ||
604 | void QPEApplication::tryQuit() { | ||
605 | qWarning("TryQuit!!"); | ||
606 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | ||
607 | return ; // Inside modal loop or konsole. Too hard to save state. | ||
608 | { | ||
609 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | ||
610 | e << d->appName; | ||
611 | } | ||
612 | processEvents(); | ||
613 | |||
614 | quit(); | ||
615 | } | ||
616 | void QPEApplication::hideOrQuit() { | ||
617 | qWarning("hide or close"); | ||
618 | processEvents(); | ||
619 | qWarning("past processing"); | ||
620 | |||
621 | // If we are a preloaded application we don't actually quit, so emit | ||
622 | // a System message indicating we're quasi-closing. | ||
623 | if ( d->preloaded && d->qpe_main_widget ) | ||
624 | |||
625 | { | ||
626 | qWarning("hiding"); | ||
627 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | ||
628 | e << d->appName; | ||
629 | d->qpe_main_widget->hide(); | ||
630 | } | ||
631 | else | ||
632 | quit(); | ||
633 | } | ||
453 | 634 | ||
454 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 635 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
455 | 636 | ||
456 | // The libraries with the skiff package (and possibly others) have | 637 | // The libraries with the skiff package (and possibly others) have |
457 | // completely useless implementations of builtin new and delete that | 638 | // completely useless implementations of builtin new and delete that |
458 | // use about 50% of your CPU. Here we revert to the simple libc | 639 | // use about 50% of your CPU. Here we revert to the simple libc |
459 | // functions. | 640 | // functions. |
460 | 641 | ||
461 | void* operator new[]( size_t size ) | 642 | void* operator new[]( size_t size ) |
462 | { | 643 | { |
463 | return malloc( size ); | 644 | return malloc( size ); |
464 | } | 645 | } |
465 | 646 | ||
466 | void* operator new( size_t size ) | 647 | void* operator new( size_t size ) |
467 | { | 648 | { |
468 | return malloc( size ); | 649 | return malloc( size ); |
469 | } | 650 | } |
470 | 651 | ||
471 | void operator delete[]( void* p ) | 652 | void operator delete[]( void* p ) |
472 | { | 653 | { |
473 | free( p ); | 654 | free( p ); |
474 | } | 655 | } |
475 | 656 | ||
476 | void operator delete[]( void* p, size_t /*size*/ ) | 657 | void operator delete[]( void* p, size_t /*size*/ ) |
477 | { | 658 | { |
478 | free( p ); | 659 | free( p ); |
479 | } | 660 | } |
480 | 661 | ||
481 | void operator delete( void* p ) | 662 | void operator delete( void* p ) |
482 | { | 663 | { |
483 | free( p ); | 664 | free( p ); |
484 | } | 665 | } |
485 | 666 | ||
486 | void operator delete( void* p, size_t /*size*/ ) | 667 | void operator delete( void* p, size_t /*size*/ ) |
487 | { | 668 | { |
488 | free( p ); | 669 | free( p ); |
489 | } | 670 | } |
490 | 671 | ||
491 | #endif | 672 | #endif |
diff --git a/x11/libqpe-x11/qpe/qpeapplication.h b/x11/libqpe-x11/qpe/qpeapplication.h index cd385db..2af1c66 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.h +++ b/x11/libqpe-x11/qpe/qpeapplication.h | |||
@@ -1,70 +1,93 @@ | |||
1 | #ifndef OPIE_QPE_APPLICATION_H | 1 | #ifndef OPIE_QPE_APPLICATION_H |
2 | #define OPIE_QPE_APPLICATION_H | 2 | #define OPIE_QPE_APPLICATION_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * LGPLed | 5 | * LGPLed |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <qapplication.h> | 8 | #include <qapplication.h> |
9 | #include <qevent.h> | ||
9 | 10 | ||
10 | #include <qpe/timestring.h> | 11 | #include <qpe/timestring.h> |
11 | 12 | ||
12 | class QCopChannel; | 13 | class QCopChannel; |
13 | class QPEApplication : public QApplication { | 14 | class QPEApplication : public QApplication { |
14 | Q_OBJECT | 15 | Q_OBJECT |
15 | public: | 16 | public: |
16 | QPEApplication(int& argc, char** argv, Type=GuiClient ); | 17 | QPEApplication(int& argc, char** argv, Type=GuiClient ); |
17 | ~QPEApplication(); | 18 | ~QPEApplication(); |
18 | 19 | ||
20 | |||
19 | static QString qpeDir(); | 21 | static QString qpeDir(); |
20 | static QString documentDir(); | 22 | static QString documentDir(); |
21 | void applyStyle(); | 23 | void applyStyle(); |
22 | 24 | ||
23 | static int defaultRotation(); | 25 | static int defaultRotation(); |
24 | static void setDefaultRotation( int r ); | 26 | static void setDefaultRotation( int r ); |
25 | static void grabKeyboard(); | 27 | static void grabKeyboard(); |
26 | static void ungrabKeyboard(); | 28 | static void ungrabKeyboard(); |
27 | 29 | ||
28 | enum StylusMode { | 30 | enum StylusMode { |
29 | LeftOnly, | 31 | LeftOnly, |
30 | RightOnHold | 32 | RightOnHold |
31 | }; | 33 | }; |
32 | static void setStylusOperation( QWidget*, StylusMode ); | 34 | static void setStylusOperation( QWidget*, StylusMode ); |
33 | static StylusMode stylusOperation( QWidget* ); | 35 | static StylusMode stylusOperation( QWidget* ); |
34 | 36 | ||
37 | enum InputMethodHint { | ||
38 | Normal, | ||
39 | AlwaysOff, | ||
40 | AlwaysOn | ||
41 | }; | ||
42 | static void setInputMethodHint( QWidget*, InputMethodHint ); | ||
43 | static InputMethodHint inputMethodHint( QWidget* ); | ||
44 | |||
35 | void showMainWidget( QWidget*, bool nomax = FALSE ); | 45 | void showMainWidget( QWidget*, bool nomax = FALSE ); |
36 | void showMainDocumentWidget( QWidget*, bool nomax = FALSE ); | 46 | void showMainDocumentWidget( QWidget*, bool nomax = FALSE ); |
37 | 47 | ||
38 | static void showDialog( QDialog*, bool nomax = FALSE ); | 48 | static void showDialog( QDialog*, bool nomax = FALSE ); |
39 | static int execDialog( QDialog*, bool nomax = FALSE ); | 49 | static int execDialog( QDialog*, bool nomax = FALSE ); |
40 | 50 | ||
41 | static void setKeepRunning(); | 51 | static void setKeepRunning(); |
42 | bool keepRunning()const; | 52 | bool keepRunning()const; |
43 | 53 | ||
44 | bool keyboardGrabbed()const; | 54 | bool keyboardGrabbed()const; |
45 | int exec(); | 55 | int exec(); |
46 | 56 | ||
47 | signals: | 57 | signals: |
48 | void clientMoused(); | 58 | void clientMoused(); |
49 | void timeChanged(); | 59 | void timeChanged(); |
50 | void clockChanged( bool pm ); | 60 | void clockChanged( bool pm ); |
51 | void micChanged( bool muted ); | 61 | void micChanged( bool muted ); |
52 | void volumeChanged( bool muted ); | 62 | void volumeChanged( bool muted ); |
53 | void appMessage( const QCString& msg, const QByteArray& data); | 63 | void appMessage( const QCString& msg, const QByteArray& data); |
54 | void weekChanged( bool startOnMonday ); | 64 | void weekChanged( bool startOnMonday ); |
55 | void dateFormatChanged( DateFormat ); | 65 | void dateFormatChanged( DateFormat ); |
56 | void flush(); | 66 | void flush(); |
57 | void reload(); | 67 | void reload(); |
58 | 68 | ||
59 | private: | 69 | private: |
60 | void initTranslations(); | 70 | void initTranslations(); |
61 | void internalSetStyle(const QString&); | 71 | void internalSetStyle(const QString&); |
62 | 72 | ||
73 | private slots: | ||
74 | void hideOrQuit(); | ||
75 | void systemMessage( const QCString&, const QByteArray& ); | ||
76 | void pidMessage( const QCString&, const QByteArray& ); | ||
77 | void removeSenderFromStylusDict(); | ||
78 | protected: | ||
79 | virtual void restart(); | ||
80 | virtual void shutdown(); | ||
81 | bool eventFilter( QObject*, QEvent* ); | ||
82 | void timerEvent( QTimerEvent* ); | ||
83 | void raiseAppropriateWindow(); | ||
84 | virtual void tryQuit(); | ||
85 | |||
63 | private: | 86 | private: |
64 | class Private; | 87 | class Private; |
65 | Private* d; | 88 | Private* d; |
66 | QCopChannel *m_sys; | 89 | QCopChannel *m_sys; |
67 | QCopChannel *m_pid; | 90 | QCopChannel *m_pid; |
68 | }; | 91 | }; |
69 | 92 | ||
70 | #endif | 93 | #endif |