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