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/ipc/client | |
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 |
2 files changed, 24 insertions, 1 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 | |||
@@ -4,4 +4,5 @@ | |||
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 | ||
@@ -17,13 +18,23 @@ 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; |
@@ -37,4 +48,5 @@ void OCOPClient::init( const QCString& ) { | |||
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; |
@@ -128,2 +140,11 @@ void OCOPClient::call( const OCOPPacket& pack ) { | |||
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 | |||
@@ -45,7 +45,9 @@ 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& ); |
@@ -53,5 +55,5 @@ private: | |||
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 | }; |