-rw-r--r-- | core/qws/qcopbridge.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/qws/qcopbridge.cpp b/core/qws/qcopbridge.cpp index c0c52e8..4fd0807 100644 --- a/core/qws/qcopbridge.cpp +++ b/core/qws/qcopbridge.cpp | |||
@@ -9,118 +9,118 @@ | |||
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qcopbridge.h" | 21 | #include "qcopbridge.h" |
22 | #include "transferserver.h" | 22 | #include "transferserver.h" |
23 | 23 | ||
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/version.h> | 26 | #include <qpe/version.h> |
27 | 27 | ||
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #ifdef QWS | 29 | #ifdef QWS |
30 | #include <qcopchannel_qws.h> | 30 | #include <qcopchannel_qws.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #define _XOPEN_SOURCE | 33 | #define _XOPEN_SOURCE |
34 | #include <pwd.h> | 34 | #include <pwd.h> |
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | #if defined(_OS_LINUX_) | 38 | #if defined(_OS_LINUX_) |
39 | #include <shadow.h> | 39 | #include <shadow.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | //#define INSECURE | 42 | //#define INSECURE |
43 | 43 | ||
44 | const int block_size = 51200; | 44 | const int block_size = 51200; |
45 | 45 | ||
46 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent , | 46 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent , |
47 | const char* name ) | 47 | const char* name ) |
48 | : QServerSocket( port, 1, parent, name ), | 48 | : QServerSocket( port, 1, parent, name ), |
49 | desktopChannel( 0 ), | 49 | desktopChannel( 0 ), |
50 | cardChannel( 0 ) | 50 | cardChannel( 0 ) |
51 | { | 51 | { |
52 | if ( !ok() ) | 52 | if ( !ok() ) |
53 | qWarning( "Failed to bind to port %d", port ); | 53 | qWarning( "Failed to bind to port %d", port ); |
54 | else { | 54 | else { |
55 | #ifndef QT_NO_COP | 55 | #ifndef QT_NO_COP |
56 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 56 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
57 | connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 57 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
58 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 58 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
59 | cardChannel = new QCopChannel( "QPE/Card", this ); | 59 | cardChannel = new QCopChannel( "QPE/Card", this ); |
60 | connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 60 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
61 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 61 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
62 | #endif | 62 | #endif |
63 | } | 63 | } |
64 | sendSync = FALSE; | 64 | sendSync = FALSE; |
65 | } | 65 | } |
66 | 66 | ||
67 | QCopBridge::~QCopBridge() | 67 | QCopBridge::~QCopBridge() |
68 | { | 68 | { |
69 | #ifndef QT_NO_COP | 69 | #ifndef QT_NO_COP |
70 | delete desktopChannel; | 70 | delete desktopChannel; |
71 | #endif | 71 | #endif |
72 | } | 72 | } |
73 | 73 | ||
74 | void QCopBridge::newConnection( int socket ) | 74 | void QCopBridge::newConnection( int socket ) |
75 | { | 75 | { |
76 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); | 76 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); |
77 | openConnections.append( pi ); | 77 | openConnections.append( pi ); |
78 | connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( connectionClosed( QCopBridgePI *) ) ); | 78 | connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( connectionClosed(QCopBridgePI*) ) ); |
79 | #ifndef QT_NO_COP | 79 | #ifndef QT_NO_COP |
80 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 80 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | if ( sendSync ) { | 83 | if ( sendSync ) { |
84 | pi ->startSync(); | 84 | pi ->startSync(); |
85 | sendSync = FALSE; | 85 | sendSync = FALSE; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) | 89 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) |
90 | { | 90 | { |
91 | openConnections.remove( pi ); | 91 | openConnections.remove( pi ); |
92 | if ( openConnections.count() == 0 ) { | 92 | if ( openConnections.count() == 0 ) { |
93 | #ifndef QT_NO_COP | 93 | #ifndef QT_NO_COP |
94 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 94 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
95 | #endif | 95 | #endif |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void QCopBridge::closeOpenConnections() | 99 | void QCopBridge::closeOpenConnections() |
100 | { | 100 | { |
101 | QCopBridgePI *pi; | 101 | QCopBridgePI *pi; |
102 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 102 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
103 | pi->close(); | 103 | pi->close(); |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) | 107 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) |
108 | { | 108 | { |
109 | command.stripWhiteSpace(); | 109 | command.stripWhiteSpace(); |
110 | 110 | ||
111 | int paren = command.find( "(" ); | 111 | int paren = command.find( "(" ); |
112 | if ( paren <= 0 ) { | 112 | if ( paren <= 0 ) { |
113 | qDebug("DesktopMessage: bad qcop syntax"); | 113 | qDebug("DesktopMessage: bad qcop syntax"); |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | 116 | ||
117 | QString params = command.mid( paren + 1 ); | 117 | QString params = command.mid( paren + 1 ); |
118 | if ( params[params.length()-1] != ')' ) { | 118 | if ( params[params.length()-1] != ')' ) { |
119 | qDebug("DesktopMessage: bad qcop syntax"); | 119 | qDebug("DesktopMessage: bad qcop syntax"); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | 122 | ||
123 | params.truncate( params.length()-1 ); | 123 | params.truncate( params.length()-1 ); |
124 | 124 | ||
125 | QStringList paramList = QStringList::split( ",", params ); | 125 | QStringList paramList = QStringList::split( ",", params ); |
126 | QString data; | 126 | QString data; |