summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/ui/opimmainwindow.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/ui/opimmainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
index 10ed743..40dc297 100644
--- a/libopie2/opiepim/ui/opimmainwindow.cpp
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -1,149 +1,149 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qapplication.h> 29#include <qapplication.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31#include <qcopchannel_qws.h> 31#include <qcopchannel_qws.h>
32 32
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36 36
37#include <opie2/opimresolver.h> 37#include <opie2/opimresolver.h>
38#include "opimmainwindow.h" 38#include "opimmainwindow.h"
39 39
40namespace Opie { 40namespace Opie {
41OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, 41OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
42 const char* name, WFlags flag ) 42 const char* name, WFlags flag )
43 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { 43 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) {
44 44
45 /* 45 /*
46 * let's generate our QCopChannel 46 * let's generate our QCopChannel
47 */ 47 */
48 m_str = QString("QPE/"+m_service).local8Bit(); 48 m_str = QString("QPE/"+m_service).local8Bit();
49 m_channel= new QCopChannel(m_str, this ); 49 m_channel= new QCopChannel(m_str, this );
50 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), 50 connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ),
51 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 51 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
52 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), 52 connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&) ),
53 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 53 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
54 54
55 /* connect flush and reload */ 55 /* connect flush and reload */
56 connect(qApp, SIGNAL(flush() ), 56 connect(qApp, SIGNAL(flush() ),
57 this, SLOT(flush() ) ); 57 this, SLOT(flush() ) );
58 connect(qApp, SIGNAL(reload() ), 58 connect(qApp, SIGNAL(reload() ),
59 this, SLOT(reload() ) ); 59 this, SLOT(reload() ) );
60} 60}
61OPimMainWindow::~OPimMainWindow() { 61OPimMainWindow::~OPimMainWindow() {
62 delete m_channel; 62 delete m_channel;
63} 63}
64QCopChannel* OPimMainWindow::channel() { 64QCopChannel* OPimMainWindow::channel() {
65 return m_channel; 65 return m_channel;
66} 66}
67void OPimMainWindow::doSetDocument( const QString& ) { 67void OPimMainWindow::doSetDocument( const QString& ) {
68 68
69} 69}
70void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { 70void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
71 bool needShow = false; 71 bool needShow = false;
72 /* 72 /*
73 * create demands to create 73 * create demands to create
74 * a new record... 74 * a new record...
75 */ 75 */
76 QDataStream stream(array, IO_ReadOnly); 76 QDataStream stream(array, IO_ReadOnly);
77 if ( cmd == "create()" ) { 77 if ( cmd == "create()" ) {
78 raise(); 78 raise();
79 int uid = create(); 79 int uid = create();
80 QCopEnvelope e(m_str, "created(int)" ); 80 QCopEnvelope e(m_str, "created(int)" );
81 e << uid; 81 e << uid;
82 needShow = true; 82 needShow = true;
83 }else if ( cmd == "remove(int)" ) { 83 }else if ( cmd == "remove(int)" ) {
84 int uid; 84 int uid;
85 stream >> uid; 85 stream >> uid;
86 bool rem = remove( uid ); 86 bool rem = remove( uid );
87 QCopEnvelope e(m_str, "removed(bool)" ); 87 QCopEnvelope e(m_str, "removed(bool)" );
88 e << rem; 88 e << rem;
89 needShow = true; 89 needShow = true;
90 }else if ( cmd == "beam(int)" ) { 90 }else if ( cmd == "beam(int)" ) {
91 int uid; 91 int uid;
92 stream >> uid; 92 stream >> uid;
93 beam( uid); 93 beam( uid);
94 }else if ( cmd == "show(int)" ) { 94 }else if ( cmd == "show(int)" ) {
95 raise(); 95 raise();
96 int uid; 96 int uid;
97 stream >> uid; 97 stream >> uid;
98 show( uid ); 98 show( uid );
99 needShow = true; 99 needShow = true;
100 }else if ( cmd == "edit(int)" ) { 100 }else if ( cmd == "edit(int)" ) {
101 raise(); 101 raise();
102 int uid; 102 int uid;
103 stream >> uid; 103 stream >> uid;
104 edit( uid ); 104 edit( uid );
105 }else if ( cmd == "add(int,QByteArray)" ) { 105 }else if ( cmd == "add(int,QByteArray)" ) {
106 int rtti; 106 int rtti;
107 QByteArray array; 107 QByteArray array;
108 stream >> rtti; 108 stream >> rtti;
109 stream >> array; 109 stream >> array;
110 m_fallBack = record(rtti, array ); 110 m_fallBack = record(rtti, array );
111 if (!m_fallBack) return; 111 if (!m_fallBack) return;
112 add( *m_fallBack ); 112 add( *m_fallBack );
113 delete m_fallBack; 113 delete m_fallBack;
114 }else if ( cmd == "alarm(QDateTime,int)" ) { 114 }else if ( cmd == "alarm(QDateTime,int)" ) {
115 raise(); 115 raise();
116 QDateTime dt; int uid; 116 QDateTime dt; int uid;
117 stream >> dt; 117 stream >> dt;
118 stream >> uid; 118 stream >> uid;
119 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); 119 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid );
120 QDateTime current = QDateTime::currentDateTime(); 120 QDateTime current = QDateTime::currentDateTime();
121 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) 121 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
122 return; 122 return;
123 doAlarm( dt, uid ); 123 doAlarm( dt, uid );
124 needShow = true; 124 needShow = true;
125 } 125 }
126 126
127 if (needShow ) 127 if (needShow )
128 QPEApplication::setKeepRunning(); 128 QPEApplication::setKeepRunning();
129} 129}
130/* implement the url scripting here */ 130/* implement the url scripting here */
131void OPimMainWindow::setDocument( const QString& str) { 131void OPimMainWindow::setDocument( const QString& str) {
132 doSetDocument( str ); 132 doSetDocument( str );
133} 133}
134/* 134/*
135 * we now try to get the array demarshalled 135 * we now try to get the array demarshalled
136 * check if the rtti matches this one 136 * check if the rtti matches this one
137 */ 137 */
138OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { 138OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) {
139 if ( service() != rtti ) 139 if ( service() != rtti )
140 return 0l; 140 return 0l;
141 141
142 OPimRecord* record = OPimResolver::self()->record( rtti ); 142 OPimRecord* record = OPimResolver::self()->record( rtti );
143 QDataStream str(array, IO_ReadOnly ); 143 QDataStream str(array, IO_ReadOnly );
144 if ( !record || !record->loadFromStream(str) ) { 144 if ( !record || !record->loadFromStream(str) ) {
145 delete record; 145 delete record;
146 record = 0l; 146 record = 0l;
147 } 147 }
148 148
149 return record; 149 return record;