~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to doc/html/sfwecho-sfwecho-client-main-cpp.html

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    </div>
47
47
    <div id="shortCut">
48
48
      <ul>
49
 
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Mobility 1.1 BETA</a></span></li>
 
49
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Mobility 1.1</a></span></li>
50
50
        <li class="shortCut-topleft-active"><a href="http://doc.qt.nokia.com">ALL VERSIONS        </a></li>
51
51
      </ul>
52
52
     </div>
150
150
 ** $QT_BEGIN_LICENSE:LGPL$
151
151
 ** Commercial Usage
152
152
 ** Licensees holding valid Qt Commercial licenses may use this file in
153
 
 ** accordance with the Qt Solutions Commercial License Agreement provided
154
 
 ** with the Software or, alternatively, in accordance with the terms
 
153
 ** accordance with the Qt Commercial License Agreement provided with
 
154
 ** the Software or, alternatively, in accordance with the terms
155
155
 ** contained in a written agreement between you and Nokia.
156
156
 **
157
157
 ** GNU Lesser General Public License Usage
174
174
 ** ensure the GNU General Public License version 3.0 requirements will be
175
175
 ** met: http://www.gnu.org/copyleft/gpl.html.
176
176
 **
177
 
 ** Please note Third Party Software included with Qt Solutions may impose
178
 
 ** additional restrictions and it is the user's responsibility to ensure
179
 
 ** that they have met the licensing requirements of the GPL, LGPL, or Qt
180
 
 ** Solutions Commercial license and the relevant license of the Third
181
 
 ** Party Software they are using.
182
 
 **
183
177
 ** If you are unsure which license is appropriate for your use, please
184
178
 ** contact the sales department at qt-sales@nokia.com.
185
179
 ** $QT_END_LICENSE$
216
210
     {
217
211
         setupUi(this);
218
212
 
219
 
         sharedEcho = 0;
220
 
         uniqueEcho = 0;
 
213
         globalEcho = 0;
 
214
         privateEcho = 0;
221
215
         echo = 0;
222
216
 
223
 
         <span class="comment">// Set default connection to the echo shared server</span>
224
 
         on_sharedChat_toggled(true);
 
217
         <span class="comment">// Set default connection to the echo global server</span>
 
218
         on_globalChat_toggled(true);
225
219
     }
226
220
 
227
221
     ~EchoClient()
238
232
         QMetaObject::invokeMethod(echo, &quot;sendMessage&quot;, Q_ARG(QString, message));
239
233
     }
240
234
 
241
 
     void on_sharedChat_toggled(bool checked)
 
235
     void on_globalChat_toggled(bool checked)
242
236
     {
243
 
         uniqueChat-&gt;setChecked(!checked);
 
237
         privateChat-&gt;setChecked(!checked);
244
238
         if (checked) {
245
239
             if (!connectToChat())
246
 
                 echoBox-&gt;append(&quot;**Unable to connect to shared Echo Chat server**&quot;);
 
240
                 echoBox-&gt;append(&quot;**Unable to connect to global Echo Chat server**&quot;);
247
241
             else
248
 
                 echoBox-&gt;append(&quot;**Connected to shared Echo Chat server**&quot;);
 
242
                 echoBox-&gt;append(&quot;**Connected to global Echo Chat server**&quot;);
249
243
         }
250
244
     }
251
245
 
252
 
     void on_uniqueChat_toggled(bool checked)
 
246
     void on_privateChat_toggled(bool checked)
253
247
     {
254
 
         sharedChat-&gt;setChecked(!checked);
 
248
         globalChat-&gt;setChecked(!checked);
255
249
         if (checked) {
256
250
             if (!connectToChat())
257
 
                 echoBox-&gt;append(&quot;**Unable to connect to unique Echo Chat server**&quot;);
 
251
                 echoBox-&gt;append(&quot;**Unable to connect to private Echo Chat server**&quot;);
258
252
             else
259
 
                 echoBox-&gt;append(&quot;**Connected to unique Echo Chat server**&quot;);
 
253
                 echoBox-&gt;append(&quot;**Connected to private Echo Chat server**&quot;);
260
254
         }
261
255
     }
262
256
 
266
260
         echoBox-&gt;append(newMsg);
267
261
     }
268
262
 
269
 
     void errorIPC()
 
263
     void errorIPC(QService::UnrecoverableIPCError error)
270
264
     {
271
265
       QDateTime ts = QDateTime::currentDateTime();
272
 
       QString newMsg = &quot;[&quot; + ts.toString(&quot;hh:mm&quot;) + &quot;]&quot; + &quot; &quot; + &quot;IPC Error&quot;;
 
266
       QString newMsg = &quot;[&quot; + ts.toString(&quot;hh:mm&quot;) + &quot;]&quot; + &quot; &quot; + &quot;IPC Error! &quot;;
 
267
 
 
268
       if (error == QService::ErrorServiceNoLongerAvailable)
 
269
           newMsg += &quot;Service no longer available&quot;;
 
270
 
273
271
       echoBox-&gt;append(newMsg);
274
272
     }
275
273
 
276
274
 private:
277
 
     QObject *sharedEcho;
278
 
     QObject *uniqueEcho;
 
275
     QObject *globalEcho;
 
276
     QObject *privateEcho;
279
277
     QObject *echo;
280
278
 
281
279
     bool connectToChat()
282
280
     {
283
 
         <span class="comment">// 0 for unique and 1 for shared</span>
 
281
         <span class="comment">// 0 for private and 1 for global</span>
284
282
         int version = 0;
285
 
         if (sharedChat-&gt;isChecked())
 
283
         if (globalChat-&gt;isChecked())
286
284
             version = 1;
287
285
 
288
 
         <span class="comment">// Set to unique server if it previously existed</span>
289
 
         if (uniqueEcho &amp;&amp; version == 0) {
290
 
             echo = uniqueEcho;
 
286
         <span class="comment">// Set to private server if it previously existed</span>
 
287
         if (privateEcho &amp;&amp; version == 0) {
 
288
             echo = privateEcho;
291
289
             return true;
292
290
         }
293
291
 
294
 
         <span class="comment">// Set to shared server if it previously existed</span>
295
 
         if (sharedEcho &amp;&amp; version == 1) {
296
 
             echo = sharedEcho;
 
292
         <span class="comment">// Set to global server if it previously existed</span>
 
293
         if (globalEcho &amp;&amp; version == 1) {
 
294
             echo = globalEcho;
297
295
             return true;
298
296
         }
299
297
 
301
299
         QServiceManager manager;
302
300
         QList&lt;QServiceInterfaceDescriptor&gt; list = manager.findInterfaces(&quot;EchoService&quot;);
303
301
         if(list.count() &lt; version+1){
304
 
             echoBox-&gt;append(&quot;Unable to find a registered service&quot;);
 
302
             echoBox-&gt;append(&quot;**Unable to find a registered service**&quot;);
305
303
             return false;
306
304
         }
307
305
 
318
316
         }
319
317
 
320
318
         if (version == 0) {
321
 
             uniqueEcho = service;
322
 
             echo = uniqueEcho;
 
319
             privateEcho = service;
 
320
             echo = privateEcho;
323
321
         } else {
324
 
             sharedEcho = service;
325
 
             echo = sharedEcho;
 
322
             globalEcho = service;
 
323
             echo = globalEcho;
326
324
         }
327
325
 
328
326
         echo-&gt;setParent(this);
331
329
         QObject::connect(echo, SIGNAL(broadcastMessage(QString,QDateTime)),
332
330
                          this, SLOT(receivedMessage(QString,QDateTime)));
333
331
 
 
332
         <span class="comment">// Connect IPC errors</span>
334
333
         QObject::connect(echo, SIGNAL(errorUnrecoverableIPCFault(QService::UnrecoverableIPCError)),
335
 
                          this, SLOT(errorIPC()));
 
334
                          this, SLOT(errorIPC(QService::UnrecoverableIPCError)));
336
335
 
337
336
         return true;
338
337
     }