summaryrefslogtreecommitdiff
path: root/libopie/pim/opimmainwindow.cpp
Unidiff
Diffstat (limited to 'libopie/pim/opimmainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/opimmainwindow.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp
new file mode 100644
index 0000000..92be2fd
--- a/dev/null
+++ b/libopie/pim/opimmainwindow.cpp
@@ -0,0 +1,71 @@
1#include <qapplication.h>
2#include <qcopchannel_qws.h>
3
4#include <qpe/qcopenvelope_qws.h>
5
6#include "opimmainwindow.h"
7
8OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
9 const char* name, WFlags flag )
10 : QMainWindow( parent, name, flag ), m_service( service ), m_fallBack(0l) {
11
12 /*
13 * let's generate our QCopChannel
14 */
15 m_str = QString("QPE/"+m_service).local8Bit();
16 m_channel= new QCopChannel(m_str, this );
17 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ),
18 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
19
20 /* connect flush and reload */
21 connect(qApp, SIGNAL(flush() ),
22 this, SLOT(flush() ) );
23 connect(qApp, SIGNAL(reload() ),
24 this, SLOT(reload() ) );
25}
26OPimMainWindow::~OPimMainWindow() {
27 delete m_channel;
28}
29QCopChannel* OPimMainWindow::channel() {
30 return m_channel;
31}
32void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
33 /*
34 * create demands to create
35 * a new record...
36 */
37 QDataStream stream(array, IO_ReadOnly);
38 if ( cmd == "create()" ) {
39 int uid = create();
40 QCopEnvelope e(m_str, "created(int)" );
41 e << uid;
42 }else if ( cmd == "remove(int)" ) {
43 int uid;
44 stream >> uid;
45 bool rem = remove( uid );
46 QCopEnvelope e(m_str, "removed(bool)" );
47 e << rem;
48 }else if ( cmd == "beam(int,int)" ) {
49 int uid, trans;
50 stream >> uid;
51 stream >> trans;
52 beam( uid, trans );
53 }else if ( cmd == "show(int)" ) {
54 int uid;
55 stream >> uid;
56 show( uid );
57 }else if ( cmd == "edit(int)" ) {
58 int uid;
59 stream >> uid;
60 edit( uid );
61 }else if ( cmd == "add(int,QByteArray)" ) {
62 int rtti;
63 QByteArray array;
64 stream >> rtti;
65 stream >> array;
66 m_fallBack = record(rtti, array );
67 if (!m_fallBack) return;
68 add( *m_fallBack );
69 delete m_fallBack;
70 }
71}