Diffstat (limited to 'libopie2/opiepim/ui/opimmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp index 92be2fd..7e57f3a 100644 --- a/libopie2/opiepim/ui/opimmainwindow.cpp +++ b/libopie2/opiepim/ui/opimmainwindow.cpp | |||
@@ -1,71 +1,105 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qcopchannel_qws.h> | 2 | #include <qcopchannel_qws.h> |
3 | 3 | ||
4 | #include <qpe/qcopenvelope_qws.h> | 4 | #include <qpe/qcopenvelope_qws.h> |
5 | 5 | ||
6 | #include "opimresolver.h" | ||
6 | #include "opimmainwindow.h" | 7 | #include "opimmainwindow.h" |
7 | 8 | ||
8 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | 9 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, |
9 | const char* name, WFlags flag ) | 10 | const char* name, WFlags flag ) |
10 | : QMainWindow( parent, name, flag ), m_service( service ), m_fallBack(0l) { | 11 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { |
11 | 12 | ||
12 | /* | 13 | /* |
13 | * let's generate our QCopChannel | 14 | * let's generate our QCopChannel |
14 | */ | 15 | */ |
15 | m_str = QString("QPE/"+m_service).local8Bit(); | 16 | m_str = QString("QPE/"+m_service).local8Bit(); |
16 | m_channel= new QCopChannel(m_str, this ); | 17 | m_channel= new QCopChannel(m_str, this ); |
17 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), | 18 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), |
18 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 19 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
19 | 20 | ||
20 | /* connect flush and reload */ | 21 | /* connect flush and reload */ |
21 | connect(qApp, SIGNAL(flush() ), | 22 | connect(qApp, SIGNAL(flush() ), |
22 | this, SLOT(flush() ) ); | 23 | this, SLOT(flush() ) ); |
23 | connect(qApp, SIGNAL(reload() ), | 24 | connect(qApp, SIGNAL(reload() ), |
24 | this, SLOT(reload() ) ); | 25 | this, SLOT(reload() ) ); |
25 | } | 26 | } |
26 | OPimMainWindow::~OPimMainWindow() { | 27 | OPimMainWindow::~OPimMainWindow() { |
27 | delete m_channel; | 28 | delete m_channel; |
28 | } | 29 | } |
29 | QCopChannel* OPimMainWindow::channel() { | 30 | QCopChannel* OPimMainWindow::channel() { |
30 | return m_channel; | 31 | return m_channel; |
31 | } | 32 | } |
33 | void OPimMainWindow::doSetDocument( const QString& ) { | ||
34 | |||
35 | } | ||
32 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { | 36 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { |
33 | /* | 37 | /* |
34 | * create demands to create | 38 | * create demands to create |
35 | * a new record... | 39 | * a new record... |
36 | */ | 40 | */ |
37 | QDataStream stream(array, IO_ReadOnly); | 41 | QDataStream stream(array, IO_ReadOnly); |
38 | if ( cmd == "create()" ) { | 42 | if ( cmd == "create()" ) { |
39 | int uid = create(); | 43 | int uid = create(); |
40 | QCopEnvelope e(m_str, "created(int)" ); | 44 | QCopEnvelope e(m_str, "created(int)" ); |
41 | e << uid; | 45 | e << uid; |
42 | }else if ( cmd == "remove(int)" ) { | 46 | }else if ( cmd == "remove(int)" ) { |
43 | int uid; | 47 | int uid; |
44 | stream >> uid; | 48 | stream >> uid; |
45 | bool rem = remove( uid ); | 49 | bool rem = remove( uid ); |
46 | QCopEnvelope e(m_str, "removed(bool)" ); | 50 | QCopEnvelope e(m_str, "removed(bool)" ); |
47 | e << rem; | 51 | e << rem; |
48 | }else if ( cmd == "beam(int,int)" ) { | 52 | }else if ( cmd == "beam(int,int)" ) { |
49 | int uid, trans; | 53 | int uid, trans; |
50 | stream >> uid; | 54 | stream >> uid; |
51 | stream >> trans; | 55 | stream >> trans; |
52 | beam( uid, trans ); | 56 | beam( uid, trans ); |
53 | }else if ( cmd == "show(int)" ) { | 57 | }else if ( cmd == "show(int)" ) { |
54 | int uid; | 58 | int uid; |
55 | stream >> uid; | 59 | stream >> uid; |
56 | show( uid ); | 60 | show( uid ); |
57 | }else if ( cmd == "edit(int)" ) { | 61 | }else if ( cmd == "edit(int)" ) { |
58 | int uid; | 62 | int uid; |
59 | stream >> uid; | 63 | stream >> uid; |
60 | edit( uid ); | 64 | edit( uid ); |
61 | }else if ( cmd == "add(int,QByteArray)" ) { | 65 | }else if ( cmd == "add(int,QByteArray)" ) { |
62 | int rtti; | 66 | int rtti; |
63 | QByteArray array; | 67 | QByteArray array; |
64 | stream >> rtti; | 68 | stream >> rtti; |
65 | stream >> array; | 69 | stream >> array; |
66 | m_fallBack = record(rtti, array ); | 70 | m_fallBack = record(rtti, array ); |
67 | if (!m_fallBack) return; | 71 | if (!m_fallBack) return; |
68 | add( *m_fallBack ); | 72 | add( *m_fallBack ); |
69 | delete m_fallBack; | 73 | delete m_fallBack; |
70 | } | 74 | } |
71 | } | 75 | } |
76 | /* implement the url scripting here */ | ||
77 | void OPimMainWindow::setDocument( const QString& str) { | ||
78 | doSetDocument( str ); | ||
79 | } | ||
80 | /* | ||
81 | * we now try to get the array demarshalled | ||
82 | * check if the rtti matches this one | ||
83 | */ | ||
84 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { | ||
85 | if ( service() != rtti ) | ||
86 | return 0l; | ||
87 | |||
88 | OPimRecord* record = OPimResolver::self()->record( rtti ); | ||
89 | QDataStream str(array, IO_ReadOnly ); | ||
90 | if ( !record || !record->loadFromStream(str) ) { | ||
91 | delete record; | ||
92 | record = 0l; | ||
93 | } | ||
94 | |||
95 | return record; | ||
96 | } | ||
97 | /* | ||
98 | * get the rtti for the service | ||
99 | */ | ||
100 | int OPimMainWindow::service() { | ||
101 | if ( m_rtti == -1 ) | ||
102 | m_rtti = OPimResolver::self()->serviceId( m_service ); | ||
103 | |||
104 | return m_rtti; | ||
105 | } | ||