diff options
Diffstat (limited to 'contrib/symbian')
32 files changed, 4672 insertions, 0 deletions
diff --git a/contrib/symbian/gnapplet.ini b/contrib/symbian/gnapplet.ini new file mode 100644 index 0000000..d0fb7ea --- /dev/null +++ b/contrib/symbian/gnapplet.ini @@ -0,0 +1,7 @@ +irda_support = 1 +bt_support = 1 +bt_rfchannel = 14 +tcp_support = 0 +tcp_port = 1912 +init_timeout = 30 +reinit_timeout = 5 diff --git a/contrib/symbian/gnapplet.sis b/contrib/symbian/gnapplet.sis Binary files differnew file mode 100644 index 0000000..1b37e28 --- /dev/null +++ b/contrib/symbian/gnapplet.sis diff --git a/contrib/symbian/gnapplet/ChangeLog b/contrib/symbian/gnapplet/ChangeLog new file mode 100644 index 0000000..9514424 --- /dev/null +++ b/contrib/symbian/gnapplet/ChangeLog @@ -0,0 +1,102 @@ +0.6.12 +====== + +0.6.11 +====== + * protocol handling: + o end time and location support added to the calendar (BORBELY Zoltan) + +0.6.10 +====== + +0.6.9 +===== + * device layer updates: + o initial TCP/IP support (BORBELY Zoltan) + +0.6.8 +===== + +0.6.7 +===== + +0.6.6 +===== + +0.6.5 +===== + * protocol handling: + o input/output buffers moved to the heap (BORBELY Zoltan) + o getprofile support added (BORBELY Zoltan) + o getactiveprofile support added (BORBELY Zoltan) + * general updates: + o rfcomm channel modified in the ini file to match default (BORBELY Zoltan) + o init_timeout, reinit_timeout parameters added to the ini file, + gnapplet can stay open between connections (BORBELY Zoltan) + o absolute path eliminated from the frontend application (BORBELY Zoltan) + o infinite timeout is now possible (BORBELY Zoltan) + +0.6.4 +===== + * protocol handling: + o deletesms support added (BORBELY Zoltan) + o movesms support added (BORBELY Zoltan) + o getsmscenter won't return error when an entry is empty (BORBELY Zoltan) + o experimental and non-working setsmscenter support (BORBELY Zoltan) + o getcalendarnote support added (Antti P Miettinen, BORBELY Zoltan) + o deletecalendarnote support added (BORBELY Zoltan) + o writecalendarnote support added (BORBELY Zoltan) + o writecalendarnote and calendar alarm handling fixed (BORBELY Zoltan) + o gettodo support added (BORBELY Zoltan) + o writetodo support added (BORBELY Zoltan) + o deletetodo support added (BORBELY Zoltan) + o todo and calendar entries separated (BORBELY Zoltan) + o all kind of phone numbers can be written into the pbk (BORBELY Zoltan) + o empty fields will be skipped during phonebook reading (BORBELY Zoltan) + o getdatetime support added (BORBELY Zoltan) + o setdatetime support added (BORBELY Zoltan) + o getalarm support added (BORBELY Zoltan) + o setalarm support added (BORBELY Zoltan) + * general updates: + o configuration read from gnapplet.ini at startup (BORBELY Zoltan) + o time conversion functions moved to gnapplet.cpp (BORBELY Zoltan) + +0.6.3 +===== + +0.6.2 +===== + * protocol handling: + o sms folder support (list, status, create, delete) (BORBELY Zoltan) + o initial version of the getsms support (BORBELY Zoltan) + o contact name construction and parsing (Antti P Miettinen, BORBELY Zoltan) + o minor code cleanup in the phonebook handling code (BORBELY Zoltan) + o sms status support added (BORBELY Zoltan) + o minor cleanup (BORBELY Zoltan) + o getsms has been completly rewritten (BORBELY Zoltan) + o getsmscenter support added (BORBELY Zoltan) + o sendsms support added (BORBELY Zoltan) + +0.6.1 +===== + * device layer updates: + o initial IrCOMM (IrDA) support (BORBELY Zoltan) + o initial RfCOMM (Bluetooth) support (BORBELY Zoltan) + * protocol handling: + o phone info reports the IMEI (BORBELY Zoltan) + o phonebook reading support (BORBELY Zoltan) + o phonebook writing support (BORBELY Zoltan) + o phonebook deleting support (BORBELY Zoltan) + o memory status support added (BORBELY Zoltan) + o call log (DC/MC/RC memory) support added (BORBELY Zoltan) + o identify works properly (BORBELY Zoltan) + o gnapplet won't quit until the client disconnects (BORBELY Zoltan) + o network info and rf level can be readed (BORBELY Zoltan) + o power source and battery level can be readed (BORBELY Zoltan) + o phone can send debug messages to the PC (BORBELY Zoltan) + o phone info returns correct model on non nokia phones (BORBELY Zoltan) + o memory status limited decreased (BORBELY Zoltan) + * general updates: + o code cleanup, better resource management (BORBELY Zoltan) + * frontend application: + o initial version (BORBELY Zoltan) diff --git a/contrib/symbian/gnapplet/Makefile b/contrib/symbian/gnapplet/Makefile new file mode 100644 index 0000000..4e304a5 --- /dev/null +++ b/contrib/symbian/gnapplet/Makefile @@ -0,0 +1,58 @@ +EPOCROOT=/home/matlec/symbian_sdk_series60 +DLLTOOL=arm-epoc-pe-dlltool +LD=arm-epoc-pe-ld +AS=arm-epoc-pe-as +CC=arm-epoc-pe-gcc +CXX=arm-epoc-pe-gcc +CPP=arm-epoc-pe-cpp +PETRAN=petran +CPPFLAGS=-D_UNICODE -march=armv4t -mthumb-interwork -c -nostdinc -Wall -Wno-ctor-dtor-privacy -Wno-unknown-pragmas -D__SYMBIAN32__ -D__GCC32__ -D__EPOC32__ -D__MARM__ -D__AVKON_ELAF -D__MARM_ARMI__ -D__DLL__ $(INCLUDE) + +INCLUDE=-I/home/matlec/symbian_sdk_series60/include -I/home/matlec/symbian_sdk_series60/include/libc -I/home/matlec/Downloads/gnokii-0.6.14/include +LIBDIR=$(EPOCROOT)/Release/armi/urel +STATLIBS=$(LIBDIR)/eexe.lib $(LIBDIR)/egcc.lib $(LIBDIR)/esock.lib $(LIBDIR)/bluetooth.lib + +OBJS=gnapplet.o pkt.o device.o ircomm.o rfcomm.o tcpip.o proto_info.o proto_phonebook.o proto_netinfo.o proto_power.o proto_debug.o proto_sms.o proto_calendar.o proto_clock.o proto_profile.o +UID1=0x1000007a +UID2=0x1000007a +UID3=0x107d4df2 +LIBS=$(LIBDIR)/send.lib $(LIBDIR)/euser.lib $(LIBDIR)/insock.lib $(LIBDIR)/cntmodel.lib $(LIBDIR)/c32.lib $(LIBDIR)/charconv.lib $(LIBDIR)/plpvariant.lib $(LIBDIR)/btmanclient.lib $(LIBDIR)/logwrap.lib $(LIBDIR)/logcli.lib $(LIBDIR)/efsrv.lib $(LIBDIR)/etel.lib $(LIBDIR)/gsmbas.lib $(LIBDIR)/gsmadv.lib $(LIBDIR)/sysutil.lib $(LIBDIR)/hal.lib $(LIBDIR)/sysagt.lib $(LIBDIR)/msgs.lib $(LIBDIR)/smcm.lib $(LIBDIR)/gsmu.lib $(LIBDIR)/agnmodel.lib $(LIBDIR)/estor.lib $(LIBDIR)/etext.lib $(LIBDIR)/estlib.lib $(LIBDIR)/ealwl.lib $(LIBDIR)/profileengine.lib $(LIBDIR)/edbms.lib $(LIBDIR)/flogger.lib + +all: gnapplet.sis + +gnapplet.app: gnapplet_ui.o + $(DLLTOOL) --as=$(AS) -m arm_interwork --output-def gnapplet.inf gnapplet_ui.o + perl5.8.8 -I/home/matlec/symbian_sdk_series60/tools -S makedef.pl -Deffile gnapplet.inf -1 NewApplication__Fv gnapplet.def + $(RM) gnapplet.inf + $(DLLTOOL) --as=$(AS) -m arm_interwork --def gnapplet.def --output-exp gnapplet.exp --dllname gnapplet[$(UID3)].app + $(LD) -e _E32Dll -u _E32Dll gnapplet.exp -dll --base-file gnapplet.bas -o $@.tmp gnapplet_ui.o $(LIBDIR)/edll.lib $(LIBDIR)/edllstub.lib $(LIBDIR)/egcc.lib $(LIBDIR)/euser.lib $(LIBDIR)/apparc.lib $(LIBDIR)/cone.lib $(LIBDIR)/eikcore.lib $(LIBDIR)/avkon.lib + $(RM) gnapplet.exp $@.tmp + $(DLLTOOL) --as=$(AS) -m arm_interwork --def gnapplet.def --dllname gnapplet[$(UID3)].app --base-file gnapplet.bas --output-exp gnapplet.exp + $(RM) gnapplet.bas + $(LD) -e _E32Dll -u _E32Dll --dll gnapplet.exp -Map gnapplet.app.map -o $@.tmp gnapplet_ui.o $(LIBDIR)/edll.lib $(LIBDIR)/edllstub.lib $(LIBDIR)/egcc.lib $(LIBDIR)/euser.lib $(LIBDIR)/apparc.lib $(LIBDIR)/cone.lib $(LIBDIR)/eikcore.lib $(LIBDIR)/avkon.lib + $(RM) gnapplet.exp + $(PETRAN) $@.tmp gnapplet.app -nocall -uid1 0x10000079 -uid2 0x100039ce -uid3 $(UID3) + $(RM) $@.tmp + +gnapplet.exe: $(OBJS) + $(LD) -e _E32Startup -u _E32Startup --base-file gnapplet.bas -o $@.tmp $(OBJS) $(STATLIBS) $(LIBS) + $(RM) $@.tmp + $(DLLTOOL) --as=$(AS) -m arm_interwork --base-file gnapplet.bas --output-exp gnapplet.exp + $(RM) gnapplet.bas + $(LD) -e _E32Startup -u _E32Startup gnapplet.exp -Map gnapplet.exe.map -o $@.tmp $(OBJS) $(STATLIBS) $(LIBS) + $(RM) gnapplet.exp + $(PETRAN) $@.tmp gnapplet.exe -nocall -uid1 $(UID1) -uid2 $(UID2) -uid3 $(UID3) + $(RM) $@.tmp + +gnapplet.rsc: gnapplet.rss + $(CPP) -I. $(INCLUDE) -DLANGUAGE_en -D_UNICODE < gnapplet.rss > gnapplet.rpp + rcomp -u -ognapplet.rsc -hgnapplet.rsg -ignapplet.rss -sgnapplet.rpp + +gnapplet.sis: gnapplet.pkg gnapplet.app gnapplet.exe gnapplet.rsc gnapplet.ini + makesis gnapplet.pkg + +clean: + $(RM) *.tmp *.rsc *.rsg *.rpp *.o + +distclean: clean + $(RM) *.app.map *.exe.map *.app *.exe *.sis diff --git a/contrib/symbian/gnapplet/device.cpp b/contrib/symbian/gnapplet/device.cpp new file mode 100644 index 0000000..b522961 --- /dev/null +++ b/contrib/symbian/gnapplet/device.cpp @@ -0,0 +1,144 @@ +/* + * $Id: device.cpp,v 1.3 2005/09/01 22:28:50 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides device independent I/O support. + * + */ + +#include "device.h" + +#define GNBUS_MAGIC_BYTE 0x5a + + +void WaitFor(TRequestStatus &rs, int msec) +{ + TRequestStatus trs; + RTimer timer; + + timer.CreateLocal(); + timer.After(trs, TTimeIntervalMicroSeconds32(msec * 1000)); + + while (rs == KRequestPending && trs == KRequestPending) { + User::WaitForAnyRequest(); + } + + timer.Cancel(); + timer.Close(); +} + + +void ReadL(Device *dev, TDes8 &buf) +{ + TRequestStatus rs; + + dev->ReadL(rs, buf); + User::WaitForRequest(rs); + switch (rs.Int()) { + case KErrNone: + case KErrDisconnected: + case KErrEof: + break; + default: + User::Leave(rs.Int()); + break; + } +} + + +void WriteL(Device *dev, const TDes8 &buf) +{ + TRequestStatus rs; + + dev->WriteL(rs, buf); + WaitFor(rs, 10000); + if (rs != KErrNone) { + User::Leave(rs.Int()); + } +} + + +TBool ReadPacketL(Device *dev, int &type, TDes8 &msg) +{ + TBuf8<1> b; + TBuf8<8> header; + TUint8 checksum[2]; + int len, c; + + checksum[0] = checksum[1] = 0; + while (header.Length() < 6) { + ReadL(dev, b); + if (!b.Length()) return false; + checksum[header.Length() & 1] ^= b[0]; + header.Append(b); + } + + type = header[4]; + c = 0; + len = (header[2] << 8) + header[3]; + msg.Zero(); + while (len > 0) { + ReadL(dev, b); + checksum[c] ^= b[0]; + msg.Append(b); + c ^= 1; + len--; + } + for (len = 2 + c; len > 0; c ^= 1, len--) { + ReadL(dev, b); + checksum[c] ^= b[0]; + } + if (checksum[0] != 0x00 || checksum[1] != 0x00) { + User::Leave(666); + } + + return true; +} + + +void WritePacketL(Device *dev, int type, const TDes8 &msg) +{ + TBuf8<2048> pkt; + int i; + TUint8 checksum[2]; + + pkt.Append(GNBUS_MAGIC_BYTE); /* magic */ + pkt.Append(0); /* sequence */ + pkt.Append(msg.Length() >> 8); /* length MSB */ + pkt.Append(msg.Length() & 0xff);/* length LSB */ + pkt.Append(type); /* type */ + pkt.Append(0); /* reserved */ + pkt.Append(msg); + if (pkt.Length() & 1) pkt.Append(0); + + checksum[0] = checksum[1] = 0; + for (i = 0; i < pkt.Length(); i++) { + checksum[i & 1] ^= pkt[i]; + } + + pkt.Append(checksum[0]); + pkt.Append(checksum[1]); + + WriteL(dev, pkt); +} diff --git a/contrib/symbian/gnapplet/device.h b/contrib/symbian/gnapplet/device.h new file mode 100644 index 0000000..f7212ab --- /dev/null +++ b/contrib/symbian/gnapplet/device.h @@ -0,0 +1,51 @@ +/* + * $Id: device.h,v 1.2 2004/04/07 23:46:40 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides device independent I/O support. + * + */ + +#ifndef __GNAPPLET_DEVICE_H +#define __GNAPPLET_DEVICE_H + +#include <c32comm.h> + + +class Device { +public: + virtual ~Device() {}; + virtual void AcceptL(TRequestStatus &rs) = 0; + virtual void CloseL(void) = 0; + virtual void ReadL(TRequestStatus &rs, TDes8 &buf) = 0; + virtual void WriteL(TRequestStatus &rs, const TDes8 &buf) = 0; +}; + +void WaitFor(TRequestStatus &rs, int msec); +void ReadL(Device *dev, TDes8 &buf); +void WriteL(Device *dev, const TDes8 &buf); +TBool ReadPacketL(Device *dev, int &type, TDes8 &msg); +void WritePacketL(Device *dev, int type, const TDes8 &msg); + +#endif diff --git a/contrib/symbian/gnapplet/gnapplet.cpp b/contrib/symbian/gnapplet/gnapplet.cpp new file mode 100644 index 0000000..3f0ac66 --- /dev/null +++ b/contrib/symbian/gnapplet/gnapplet.cpp @@ -0,0 +1,532 @@ +/* + * $Id: gnapplet.cpp,v 1.17 2005/09/01 22:28:50 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the controlling logic of the application. + * + */ + +#include "ircomm.h" +#include "rfcomm.h" +#include "tcpip.h" +#include "pkt.h" +#include "proto.h" +#include "gnapplet.h" + + +static bool tdiff_ok = false; +static TTimeIntervalMicroSeconds tdiff; + +CConsoleBase *cons; +GNApplet *g; + + +static void LoadIni(GNApplet *g, const char *file) +{ + FILE *f; + char buf[64], key[64], value[64]; + TBuf<64> Key, Value; + TLex lexer; + TInt32 val; + + if ((f = fopen(file, "rt")) == NULL) return; + + while (fgets(buf, sizeof(buf), f) != NULL) { + if (sscanf(buf, " %[a-zA-Z0-9_] = %[a-zA-Z0-9_-]", key, value) != 2) { + continue; + } + if (key[0] == '#') { + continue; + } + TPtrC8 k((TUint8 *)key), v((TUint8 *)value); + Key.Copy(k); + Value.Copy(v); + lexer.Assign(Value); + lexer.Val(val); + if (Key == _L("irda_support")) { + g->irda_support = val; + } else if (Key == _L("bt_support")) { + g->bt_support = val; + } else if (Key == _L("bt_rfchannel")) { + g->bt_rfchannel = val; + } else if (Key == _L("init_timeout")) { + g->init_timeout = val; + } else if (Key == _L("reinit_timeout")) { + g->reinit_timeout = val; + } else if (Key == _L("tcp_support")) { + g->tcp_support = val; + } else if (Key == _L("tcp_port")) { + g->tcp_port = val; + } + } + fclose(f); +} + + +GNApplet::GNApplet(void) +{ + current_device = 0; + irda_support = true; + bt_support = true; + bt_rfchannel = 14; + tcp_support = false; + tcp_port = 1912; + init_timeout = 30; + reinit_timeout = 5; + LoadIni(this, "C:\\system\\apps\\gnapplet\\gnapplet.ini"); + + telserver = 0; + phone = 0; + sysagent = 0; + + cdb = 0; + + logfs = 0; + logclient = 0; + logview = 0; + + msv_session = 0; + mtmreg = 0; + smsmtm = 0; + + agendaserv = 0; + agendamodel = 0; + + alarmserv = 0; + + profile = 0; + profilefs = 0; +} + + +GNApplet::~GNApplet() +{ + // Phone info + if (sysagent) { + delete sysagent; + } + if (phone) { + delete phone; + } + if (telserver) { + telserver->Close(); + telserver->UnloadPhoneModule(_L("phonetsy.tsy")); + delete telserver; + } + + // Phonebook + if (cdb) { + delete cdb; + } + + // Log client + if (logview) { + delete logview; + } + if (logclient) { + delete logclient; + } + if (logfs) { + logfs->Close(); + delete logfs; + } + + // SMS + if (smsmtm) { + delete smsmtm; + } + if (mtmreg) { + delete mtmreg; + } + if (msv_session) { + delete msv_session; + } + + // Calendar + if (agendamodel) { + delete agendamodel; + } + if (agendaserv) { + agendaserv->Close(); + delete agendaserv; + } + + // Clock & alarm + if (alarmserv) { + alarmserv->Close(); + delete alarmserv; + } + + // Profile + if (profile) { + delete profile; + } + if (profilefs) { + profilefs->Close(); + delete profilefs; + } +} + + +void GNApplet::InitPhoneInfoL(void) +{ + RTelServer::TPhoneInfo info; + + if (telserver) return; + + telserver = new (ELeave)RTelServer; + User::LeaveIfError(telserver->Connect()); + User::LeaveIfError(telserver->LoadPhoneModule(_L("phonetsy.tsy"))); + + User::LeaveIfError(telserver->GetPhoneInfo(0, info)); + phone = new (ELeave)RBasicGsmPhone; + User::LeaveIfError(phone->Open(*telserver, info.iName)); + + sysagent = new (ELeave)RSystemAgent; + User::LeaveIfError(sysagent->Connect()); +} + + +void GNApplet::InitPhoneBookL(void) +{ + if (cdb) return; + + cdb = CContactDatabase::OpenL(); + contactIter = new TContactIter( *cdb ); +} + + +void GNApplet::InitLogClientL(void) +{ + if (logview) return; + + logfs = new (ELeave)RFs; + User::LeaveIfError(logfs->Connect()); + + logclient = CLogClient::NewL(*logfs); + + logview = CLogViewEvent::NewL(*logclient); +} + + +void GNApplet::InitSmsL(MMsvSessionObserver &observer) +{ + if (msv_session) return; + + msv_session = CMsvSession::OpenSyncL(observer); + mtmreg = CClientMtmRegistry::NewL(*msv_session); + smsmtm = static_cast<CSmsClientMtm *>(mtmreg->NewMtmL(KUidMsgTypeSMS)); +} + + +void GNApplet::InitCalendarL(void) +{ + if (agendaserv) return; + + agendaserv = RAgendaServ::NewL(); + User::LeaveIfError(agendaserv->Connect()); + + agendamodel = CAgnEntryModel::NewL(); + agendamodel->SetServer(agendaserv); + agendamodel->OpenL(_L("C:\\System\\Data\\Calendar")); +} + + +void GNApplet::InitClockL(void) +{ + if (alarmserv) return; + + alarmserv = new (ELeave)RAlarmServer; + User::LeaveIfError(alarmserv->Connect()); +} + + +void GNApplet::InitProfileL(void) +{ + if (profile) return; + + profile = CProfileAPI::NewL(EFalse); + + profilefs = new (ELeave)RFs; + User::LeaveIfError(profilefs->Connect()); +} + + +void WaitIfReqL(TBool wait, TRequestStatus &status, int msec = 3000) +{ + TRequestStatus timer_status; + RTimer timer; + TInt error; + + if (!wait) return; + + timer.CreateLocal(); + timer.After(timer_status, TTimeIntervalMicroSeconds32(msec * 1000)); + + while (status == KRequestPending && timer_status == KRequestPending) { + User::WaitForAnyRequest(); + while (CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle)) ; + } + + timer.Cancel(); + timer.Close(); + + if (status != KErrNone) { + User::Leave(status.Int()); + } +} + + +TTime toUTC(const TTime t) +{ + if (!tdiff_ok) { + TTime tlocal, tutc; + + tlocal.HomeTime(); + tutc.UniversalTime(); + tdiff = tlocal.Int64() - tutc.Int64(); + tdiff_ok = true; + } + + return t - tdiff; +} + + +TTime toLOCAL(const TTime t) +{ + if (!tdiff_ok) { + TTime tlocal, tutc; + + tlocal.HomeTime(); + tutc.UniversalTime(); + tdiff = tlocal.Int64() - tutc.Int64(); + tdiff_ok = true; + } + + return t + tdiff; +} + + +static void HandleConnectionL(Device *dev) +{ + HBufC8 *b_in, *b_out; + PktBuf pkt_in, pkt_out; + int type; + + g->current_device = dev; + b_in = HBufC8::NewLC(512); + b_out = HBufC8::NewLC(512); + + do { + b_in->Des().Zero(); + b_out->Des().Zero(); + if (!ReadPacketL(dev, type, b_in->Des())) break; + pkt_in.Set((void *)b_in->Des().Ptr(), b_in->Des().Length()); + pkt_out.Set(b_out->Des().Ptr(), 512); + + switch (type) { + case GNAPPLET_MSG_INFO: + HandleInfoMsg(pkt_in, pkt_out); + break; + case GNAPPLET_MSG_PHONEBOOK: + HandlePhonebookMsg(pkt_in, pkt_out); + break; + case GNAPPLET_MSG_NETINFO: + HandleNetinfoMsg(pkt_in, pkt_out); + break; + case GNAPPLET_MSG_POWER: + HandlePowerMsg(pkt_in, pkt_out); + break; + case GNAPPLET_MSG_SMS: + HandleSMSMsg(pkt_in, pkt_out); + break; + case GNAPPLET_MSG_CALENDAR: + HandleCalendarMsg(pkt_in, pkt_out); + break; + case GNAPPLET_MSG_CLOCK: + HandleClockMsg(pkt_in, pkt_out); + break; + case GNAPPLET_MSG_PROFILE: + HandleProfileMsg(pkt_in, pkt_out); + break; + } + + b_out->Des().SetLength(pkt_out.GetOffs()); + WritePacketL(dev, type, b_out->Des()); + } while (1); + + CleanupStack::PopAndDestroy(b_out); + CleanupStack::PopAndDestroy(b_in); + g->current_device = 0; +} + + +static void MainL(void) +{ + IrCOMM *ircomm; + RfCOMM *rfcomm; + TCPIP *tcpip; + RTimer timer; + TRequestStatus ircomm_rs, rfcomm_rs, tcpip_rs, timer_rs; + + g = new GNApplet; + CleanupStack::PushL(g); + + if (g->irda_support) { + cons->Printf(_L("IrCOMM: on\r\n")); + ircomm = new IrCOMM; + CleanupStack::PushL(ircomm); + ircomm->ConstructL(); + ircomm->AcceptL(ircomm_rs); + } + + if (g->bt_support) { + cons->Printf(_L("RfCOMM: on, Ch#%d\r\n"), g->bt_rfchannel); + rfcomm = new RfCOMM; + CleanupStack::PushL(rfcomm); + rfcomm->ConstructL(g->bt_rfchannel); + rfcomm->AcceptL(rfcomm_rs); + } + + if (g->tcp_support) { + cons->Printf(_L("TCP/IP: on, Port#%u\r\n"), (int)g->tcp_port); + tcpip = new TCPIP; + CleanupStack::PushL(tcpip); + tcpip->ConstructL(g->tcp_port); + tcpip->AcceptL(tcpip_rs); + } + + cons->Printf(_L("timeout: ")); + if (g->init_timeout >= 0) { + cons->Printf(_L("%d sec/"), g->init_timeout); + } else { + cons->Printf(_L("off/")); + } + if (g->reinit_timeout >= 0) { + cons->Printf(_L("%d sec\r\n"), g->reinit_timeout); + } else { + cons->Printf(_L("off\r\n")); + } + + timer.CreateLocal(); + if (g->init_timeout >= 0) { + timer.After(timer_rs, TTimeIntervalMicroSeconds32(g->init_timeout * 1000000)); + } else { + timer_rs = KRequestPending; + } + + while (timer_rs == KRequestPending) { + User::WaitForAnyRequest(); + if (g->irda_support && ircomm_rs == KErrNone) { + cons->Printf(_L("IrCOMM connection\r\n")); + HandleConnectionL(ircomm); + ircomm->CloseL(); + ircomm->AcceptL(ircomm_rs); + timer.Cancel(); + if (g->reinit_timeout >= 0) { + timer.After(timer_rs, TTimeIntervalMicroSeconds32(g->reinit_timeout * 1000000)); + } else { + timer_rs = KRequestPending; + } + } + if (g->bt_support && rfcomm_rs == KErrNone) { + cons->Printf(_L("RfCOMM connection\r\n")); + HandleConnectionL(rfcomm); + rfcomm->CloseL(); + rfcomm->AcceptL(rfcomm_rs); + timer.Cancel(); + if (g->reinit_timeout >= 0) { + timer.After(timer_rs, TTimeIntervalMicroSeconds32(g->reinit_timeout * 1000000)); + } else { + timer_rs = KRequestPending; + } + } + if (g->tcp_support && tcpip_rs == KErrNone) { + cons->Printf(_L("TCP/IP connection\r\n")); + HandleConnectionL(tcpip); + tcpip->CloseL(); + tcpip->AcceptL(tcpip_rs); + timer.Cancel(); + if (g->reinit_timeout >= 0) { + timer.After(timer_rs, TTimeIntervalMicroSeconds32(g->reinit_timeout * 1000000)); + } else { + timer_rs = KRequestPending; + } + } + }; + + if (g->tcp_support) { + CleanupStack::PopAndDestroy(tcpip); + } + if (g->bt_support) { + CleanupStack::PopAndDestroy(rfcomm); + } + if (g->irda_support) { + CleanupStack::PopAndDestroy(ircomm); + } + CleanupStack::PopAndDestroy(g); +} + + +static void SpawnMainL(void) +{ + CActiveScheduler *sched; + TInt error; + + error = StartC32(); + if (error != KErrNone && error != KErrAlreadyExists) { + User::Leave(error); + } + + sched = new (ELeave)CActiveScheduler; + CleanupStack::PushL(sched); + CActiveScheduler::Install(sched); + + cons = Console::NewL(_L("GNAPPLET"), TSize(KDefaultConsWidth, KDefaultConsHeight)); + CleanupStack::PushL(cons); + + cons->Printf(_L("gnapplet started\n")); + MainL(); + //cons->Printf(_L("[press any key]\n")); + //cons->Getch(); + + CleanupStack::PopAndDestroy(cons); + + CleanupStack::PopAndDestroy(sched); +} + + +GLDEF_C int E32Main(void) +{ + CTrapCleanup *cleanup = CTrapCleanup::New(); + + TRAPD(error, SpawnMainL()); + if (error != KErrNone) { + User::Panic(_L("GNAPPLET"), error); + } + + delete cleanup; + + return 0; +} diff --git a/contrib/symbian/gnapplet/gnapplet.h b/contrib/symbian/gnapplet/gnapplet.h new file mode 100644 index 0000000..9be664f --- /dev/null +++ b/contrib/symbian/gnapplet/gnapplet.h @@ -0,0 +1,125 @@ +/* + * $Id: gnapplet.h,v 1.15 2005/09/01 22:28:50 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the controlling logic of the application. + * + */ + +#ifndef __GNAPPLET_H +#define __GNAPPLET_H + +#include <e32cons.h> +#include <etel.h> +#include <etelbgsm.h> +#include <etelagsm.h> +#include <cntdef.h> +#include <cntdb.h> +#include <cntitem.h> +#include <cntfldst.h> +#include <f32file.h> +#include <logcli.h> +#include <logview.h> +#include <logwrap.rsg> +#include <saclient.h> +#include <msvapi.h> +#include <msvids.h> +#include <mtclreg.h> +#include <smsclnt.h> +#include <smut.h> +#include <smuthdr.h> +#include <smutset.h> +#include <smutsimparam.h> +#include <gsmupdu.h> +#include <gsmuelem.h> +#include <agclient.h> +#include <t32alm.h> +#include <profileapi.h> + +#include "device.h" + + +class GNApplet { +public: + GNApplet(void); + ~GNApplet(void); + + // gnapplet specific + Device *current_device; + gboolean irda_support; + gboolean bt_support; + gboolean tcp_support; + int bt_rfchannel; + TUint16 tcp_port; + int init_timeout; + int reinit_timeout; + + // Phone info + RTelServer *telserver; + RBasicGsmPhone *phone; + RSystemAgent *sysagent; + void InitPhoneInfoL(void); + + // Phonebook + CContactDatabase *cdb; + TContactIter *contactIter; + void InitPhoneBookL(void); + + // Log client + RFs *logfs; + CLogClient *logclient; + CLogViewEvent *logview; + void InitLogClientL(void); + + // SMS + CMsvSession *msv_session; + CClientMtmRegistry *mtmreg; + CSmsClientMtm *smsmtm; + void InitSmsL(MMsvSessionObserver &observer); + + // Calendar + RAgendaServ *agendaserv; + CAgnEntryModel *agendamodel; + void InitCalendarL(void); + + // Clock & alarm + RAlarmServer *alarmserv; + void InitClockL(void); + + // Profile + CProfileAPI *profile; + RFs *profilefs; + void InitProfileL(void); +}; + + +extern CConsoleBase *cons; +extern GNApplet *g; + + +void WaitIfReqL(TBool wait, TRequestStatus &status, int msec = 3000); +TTime toUTC(const TTime t); +TTime toLOCAL(const TTime t); + +#endif diff --git a/contrib/symbian/gnapplet/gnapplet.ini b/contrib/symbian/gnapplet/gnapplet.ini new file mode 100644 index 0000000..d0fb7ea --- /dev/null +++ b/contrib/symbian/gnapplet/gnapplet.ini @@ -0,0 +1,7 @@ +irda_support = 1 +bt_support = 1 +bt_rfchannel = 14 +tcp_support = 0 +tcp_port = 1912 +init_timeout = 30 +reinit_timeout = 5 diff --git a/contrib/symbian/gnapplet/gnapplet.pkg b/contrib/symbian/gnapplet/gnapplet.pkg new file mode 100644 index 0000000..151e566 --- /dev/null +++ b/contrib/symbian/gnapplet/gnapplet.pkg @@ -0,0 +1,10 @@ +&EN + +#{"gnap"},(0x107d4df2),1,0,0 + +(0x101F6F88), 0, 0, 0, {"Series60ProductID"} + +"gnapplet.app"-"C:\system\apps\gnapplet\gnapplet.app" +"gnapplet.exe"-"C:\system\apps\gnapplet\gnapplet.exe" +"gnapplet.rsc"-"C:\system\apps\gnapplet\gnapplet.rsc" +"gnapplet.ini"-"C:\system\apps\gnapplet\gnapplet.ini" diff --git a/contrib/symbian/gnapplet/gnapplet.rss b/contrib/symbian/gnapplet/gnapplet.rss new file mode 100644 index 0000000..645e06f --- /dev/null +++ b/contrib/symbian/gnapplet/gnapplet.rss @@ -0,0 +1,14 @@ +NAME gnap + +#include <eikon.rh> +#include <eikon.rsg> +#include <avkon.rh> +#include <avkon.rsg> + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf = ""; } + +RESOURCE TBUF r_default_document_name { buf=""; } + +RESOURCE EIK_APP_INFO { } diff --git a/contrib/symbian/gnapplet/gnapplet_ui.cpp b/contrib/symbian/gnapplet/gnapplet_ui.cpp new file mode 100644 index 0000000..d0ba9f6 --- /dev/null +++ b/contrib/symbian/gnapplet/gnapplet_ui.cpp @@ -0,0 +1,80 @@ +/* + * $Id: gnapplet_ui.cpp,v 1.2 2005/04/12 20:18:24 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains a frontent to the real application. + * + */ + +#include "gnapplet_ui.h" + + +GLDEF_C TInt E32Dll(TDllReason) +{ + return KErrNone; +} + +EXPORT_C CApaApplication *NewApplication(void) +{ + return new CGNAppletApplication; +} + +/* ------------------------------------------------------------------------- */ + +CApaDocument *CGNAppletApplication::CreateDocumentL(void) +{ + return new (ELeave)CGNAppletDocument(*this); +} + +TUid CGNAppletApplication::AppDllUid(void) const +{ + TUid id = { 0x107d4df2 }; /* UID3 */ + + return id; +} + +/* ------------------------------------------------------------------------- */ + +CEikAppUi *CGNAppletDocument::CreateAppUiL(void) +{ + return new (ELeave)CGNAppletAppUi; +} + +/* ------------------------------------------------------------------------- */ + +void CGNAppletAppUi::ConstructL(void) +{ + TFileName file; + int pos; + + BaseConstructL(ENoAppResourceFile); + + file.Copy(Application()->AppFullName()); + pos = file.LocateReverse('\\'); + file.Replace(pos, file.Length() - pos, _L("\\gnapplet.exe")); + + EikDll::StartExeL(file); + + User::Exit(0); +} diff --git a/contrib/symbian/gnapplet/gnapplet_ui.h b/contrib/symbian/gnapplet/gnapplet_ui.h new file mode 100644 index 0000000..10e1ea5 --- /dev/null +++ b/contrib/symbian/gnapplet/gnapplet_ui.h @@ -0,0 +1,57 @@ +/* + * $Id: gnapplet_ui.h,v 1.1 2004/04/12 23:44:14 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains a frontent to the real application. + * + */ + +#ifndef __GNAPPLET_UI_H +#define __GNAPPLET_UI_H + +#include <eikdll.h> +#include <eikapp.h> +#include <eikdoc.h> +#include <eikappui.h> + + +class CGNAppletApplication: public CEikApplication { +public: + CApaDocument *CreateDocumentL(void); + TUid AppDllUid(void) const; +}; + +class CGNAppletDocument: public CEikDocument { +public: + CGNAppletDocument(CEikApplication &aApp): CEikDocument(aApp) {} + CEikAppUi *CreateAppUiL(void); +}; + +class CGNAppletAppUi: public CEikAppUi { +public: + void ConstructL(void); + void HandleCommandL(int aCommand) {} +}; + +#endif diff --git a/contrib/symbian/gnapplet/ircomm.cpp b/contrib/symbian/gnapplet/ircomm.cpp new file mode 100644 index 0000000..194adf8 --- /dev/null +++ b/contrib/symbian/gnapplet/ircomm.cpp @@ -0,0 +1,86 @@ +/* + * $Id: ircomm.cpp,v 1.1.1.1 2004/04/03 21:29:46 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides IrCOMM support. + * + */ + +#include "ircomm.h" + + +IrCOMM::~IrCOMM(void) +{ + CloseL(); + rserv.UnloadCommModule(_L("IrCOMM")); +} + + +void IrCOMM::ConstructL(void) +{ + TInt error; + + error = User::LoadPhysicalDevice(_L("EUART1")); + if (error != KErrNone && error != KErrAlreadyExists) { + User::Leave(error); + } + error = User::LoadLogicalDevice(_L("ECOMM")); + if (error != KErrNone && error != KErrAlreadyExists) { + User::Leave(error); + } + + rserv.Connect(); + rserv.LoadCommModule(_L("IrCOMM")); +} + + +void IrCOMM::AcceptL(TRequestStatus &rs) +{ + TBuf8<0> b; + TInt error; + + if ((error = rcomm.Open(rserv, _L("IrCOMM::0"), ECommExclusive)) != KErrNone) { + User::Leave(error); + } + + rcomm.Write(rs, b); +} + + +void IrCOMM::CloseL(void) +{ + rcomm.Close(); +} + + +void IrCOMM::ReadL(TRequestStatus &rs, TDes8 &buf) +{ + rcomm.Read(rs, buf); +} + + +void IrCOMM::WriteL(TRequestStatus &rs, const TDes8 &buf) +{ + rcomm.Write(rs, buf); +} diff --git a/contrib/symbian/gnapplet/ircomm.h b/contrib/symbian/gnapplet/ircomm.h new file mode 100644 index 0000000..4af6541 --- /dev/null +++ b/contrib/symbian/gnapplet/ircomm.h @@ -0,0 +1,49 @@ +/* + * $Id: ircomm.h,v 1.1.1.1 2004/04/03 21:29:46 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides IrCOMM support. + * + */ + +#ifndef __GNAPPLET_IRCOMM_H +#define __GNAPPLET_IRCOMM_H + +#include "device.h" + + +class IrCOMM: public Device { + RCommServ rserv; + RComm rcomm; +public: + IrCOMM(void) {}; + ~IrCOMM(void); + void ConstructL(void); + void AcceptL(TRequestStatus &rs); + void CloseL(void); + void ReadL(TRequestStatus &rs, TDes8 &buf); + void WriteL(TRequestStatus &rs, const TDes8 &buf); +}; + +#endif diff --git a/contrib/symbian/gnapplet/pkt.cpp b/contrib/symbian/gnapplet/pkt.cpp new file mode 100644 index 0000000..ecd2241 --- /dev/null +++ b/contrib/symbian/gnapplet/pkt.cpp @@ -0,0 +1,317 @@ +/* + * $Id: pkt.cpp,v 1.4 2004/10/11 20:29:43 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides encoding/decoding support for network communication. + * + */ + +#include "pkt.h" + + +PktBuf::PktBuf(void) +{ + addr = 0; + size = 0; + offs = 0; +} + + +PktBuf::PktBuf(void *a, TInt32 len) +{ + addr = (TUint8 *)a; + size = len; + offs = 0; +} + + +void PktBuf::Set(void *a, TInt32 len) +{ + addr = (TUint8 *)a; + size = len; + offs = 0; +} + + +TUint8 *PktBuf::ExpandL(TInt32 len) +{ + TUint8 *a; + + if (size < offs + len) User::Leave(KErrOverflow); + + a = addr + offs; + offs += len; + + return a; +} + + +PktBuf &operator<<(PktBuf &buf, TInt8 x) +{ + TUint8 *b = buf.ExpandL(1); + + b[0] = (TUint8)x; + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, TInt16 x) +{ + TUint8 *b = buf.ExpandL(2); + + b[0] = (TUint8)((x >> 8) & 0xff); + b[1] = (TUint8)(x & 0xff); + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, TInt32 x) +{ + TUint8 *b = buf.ExpandL(4); + + b[0] = (TUint8)((x >> 24) & 0xff); + b[1] = (TUint8)((x >> 16) & 0xff); + b[2] = (TUint8)((x >> 8) & 0xff); + b[3] = (TUint8)(x & 0xff); + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, TUint8 x) +{ + TUint8 *b = buf.ExpandL(1); + + b[0] = x; + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, TUint16 x) +{ + TUint8 *b = buf.ExpandL(2); + + b[0] = ((x >> 8) & 0xff); + b[1] = (x & 0xff); + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, TUint32 x) +{ + TUint8 *b = buf.ExpandL(4); + + b[0] = ((x >> 24) & 0xff); + b[1] = ((x >> 16) & 0xff); + b[2] = ((x >> 8) & 0xff); + b[3] = (x & 0xff); + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, const TDesC &x) +{ + TUint16 n = x.Length(); + TUint8 *b; + int i; + + buf << n; + + b = buf.ExpandL(2 * n); + for(i = 0; i < n; i++) { + b[2 * i] = (x[i] >> 8); + b[2 * i + 1] = (x[i] & 0xff); + } + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, const TTime &x) +{ + TTime t; + TDateTime dt; + TUint8 month, day; + + t = toLOCAL(x); + + dt = t.DateTime(); + month = dt.Month() + 1; + day = dt.Day() + 1; + + buf << (TUint16)dt.Year() << month << day; + buf << (TUint8)dt.Hour() << (TUint8)dt.Minute() << (TUint8)dt.Second(); + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, const TBool x) +{ + buf << static_cast<TUint8>(x ? 1 : 0); + + return buf; +} + + +PktBuf &operator<<(PktBuf &buf, const TDesC8 &x) +{ + TUint16 n = x.Length(); + TUint8 *b; + int i; + + buf << n; + + b = buf.ExpandL(n); + for(i = 0; i < n; i++) { + b[i] = x[i]; + } + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TInt8 &x) +{ + TUint8 *b = buf.ExpandL(1); + + x = (TInt8)b[0]; + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TInt16 &x) +{ + TUint8 *b = buf.ExpandL(2); + + x = (TInt16)((b[0] << 8) + b[1]); + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TInt32 &x) +{ + TUint8 *b = buf.ExpandL(4); + + x = (TInt32)((b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3]); + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TUint8 &x) +{ + TUint8 *b = buf.ExpandL(1); + + x = b[0]; + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TUint16 &x) +{ + TUint8 *b = buf.ExpandL(2); + + x = (b[0] << 8) + b[1]; + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TUint32 &x) +{ + TUint8 *b = buf.ExpandL(4); + + x = (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3]; + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TDes &x) +{ + TUint16 l; + TUint8 *b; + int i; + + buf >> l; + b = buf.ExpandL(2 * l); + + x.SetLength(l); + for(i = 0; i < l; i++) + x[i] = (b[2 * i] << 8) + b[2 * i + 1]; + x.ZeroTerminate(); + + return buf; +} + +PktBuf &operator>>(PktBuf &buf, TTime &x) +{ + TUint16 year; + TUint8 month, day, hour, minute, second; + TDateTime dt; + + buf >> year >> month >> day >> hour >> minute >> second; + dt.Set(year, TMonth(month - 1), day - 1, hour, minute, second, 0); + x = toUTC(TTime(dt)); + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TBool &x) +{ + TUint8 b; + + buf >> b; + + x = b ? true : false; + + return buf; +} + + +PktBuf &operator>>(PktBuf &buf, TDes8 &x) +{ + TUint16 l; + TUint8 *b; + int i; + + buf >> l; + b = buf.ExpandL(l); + + x.SetLength(l); + for(i = 0; i < l; i++) + x[i] = b[i]; + + return buf; +} diff --git a/contrib/symbian/gnapplet/pkt.h b/contrib/symbian/gnapplet/pkt.h new file mode 100644 index 0000000..ba6a29c --- /dev/null +++ b/contrib/symbian/gnapplet/pkt.h @@ -0,0 +1,77 @@ +/* + * $Id: pkt.h,v 1.4 2004/10/11 20:29:43 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides encoding/decoding support for network communication. + * + */ + +#ifndef __GNAPPLET_PKT_H +#define __GNAPPLET_PKT_H + +#include <e32std.h> +#include <sys/time.h> +typedef TUint8 uint8_t; +#include <phones/gnapplet.h> + +#include "gnapplet.h" /* toUTC, toLOCAL */ + + +class PktBuf { +private: + TUint8 *addr; + TInt32 size; + TInt32 offs; +public: + PktBuf(void); + PktBuf(void *a, TInt32 len); + void Set(void *a, TInt32 len); + TInt32 GetOffs(void) { return offs; } + TUint8 *ExpandL(TInt32 len); + void FinishL(void) { if (offs != size) User::Leave(KErrOverflow); } +}; + +PktBuf &operator<<(PktBuf &buf, TInt8 x); +PktBuf &operator<<(PktBuf &buf, TInt16 x); +PktBuf &operator<<(PktBuf &buf, TInt32 x); +PktBuf &operator<<(PktBuf &buf, TUint8 x); +PktBuf &operator<<(PktBuf &buf, TUint16 x); +PktBuf &operator<<(PktBuf &buf, TUint32 x); +PktBuf &operator<<(PktBuf &buf, const TDesC &x); +PktBuf &operator<<(PktBuf &buf, const TTime &x); +PktBuf &operator<<(PktBuf &buf, TBool x); +PktBuf &operator<<(PktBuf &buf, const TDesC8 &x); + +PktBuf &operator>>(PktBuf &buf, TInt8 &x); +PktBuf &operator>>(PktBuf &buf, TInt16 &x); +PktBuf &operator>>(PktBuf &buf, TInt32 &x); +PktBuf &operator>>(PktBuf &buf, TUint8 &x); +PktBuf &operator>>(PktBuf &buf, TUint16 &x); +PktBuf &operator>>(PktBuf &buf, TUint32 &x); +PktBuf &operator>>(PktBuf &buf, TDes &x); +PktBuf &operator>>(PktBuf &buf, TTime &x); +PktBuf &operator>>(PktBuf &buf, TBool &x); +PktBuf &operator>>(PktBuf &buf, TDes8 &x); + +#endif diff --git a/contrib/symbian/gnapplet/proto.h b/contrib/symbian/gnapplet/proto.h new file mode 100644 index 0000000..7e4bca3 --- /dev/null +++ b/contrib/symbian/gnapplet/proto.h @@ -0,0 +1,49 @@ +/* + * $Id: proto.h,v 1.7 2005/03/08 10:30:12 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the prototypes of the message handlers. + * + */ + +#ifndef __GNAPPLET_PROTO_H +#define __GNAPPLET_PROTO_H + +#include "gnapplet.h" +#include "pkt.h" + + +void Debug(TRefByValue<const TDesC> fmt, ...); + +void HandleInfoMsg(PktBuf &in, PktBuf &out); +void HandlePhonebookMsg(PktBuf &in, PktBuf &out); +void HandleNetinfoMsg(PktBuf &in, PktBuf &out); +void HandlePowerMsg(PktBuf &in, PktBuf &out); +void HandleDebugMsg(PktBuf &in, PktBuf &out); +void HandleSMSMsg(PktBuf &in, PktBuf &out); +void HandleCalendarMsg(PktBuf &in, PktBuf &out); +void HandleClockMsg(PktBuf &in, PktBuf &out); +void HandleProfileMsg(PktBuf &in, PktBuf &out); + +#endif diff --git a/contrib/symbian/gnapplet/proto_calendar.cpp b/contrib/symbian/gnapplet/proto_calendar.cpp new file mode 100644 index 0000000..c041857 --- /dev/null +++ b/contrib/symbian/gnapplet/proto_calendar.cpp @@ -0,0 +1,494 @@ +/* + * $Id: proto_calendar.cpp,v 1.6 2006/01/05 00:20:02 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the calendar and todo list message handler. + * + */ + +#include "proto.h" + + +static CAgnEntry *GetEntryL(TUint32 location, TBool istodo) +{ + CAgnEntry *entry; + TBool available, eistodo; + + available = g->agendaserv->CreateEntryIterator(); + + while (available && location > 0) { + entry = g->agendamodel->FetchEntryL(g->agendaserv->EntryIteratorPosition()); + + eistodo = (entry->Type() == CAgnEntry::ETodo); + if (eistodo && istodo || !eistodo && !istodo) { + if (--location < 1) return entry; + } + + delete entry; + available = g->agendaserv->EntryIteratorNext(); + } + + return NULL; +} + + +static void ReadCalendarNoteL(PktBuf &in, PktBuf &out) +{ + TUint32 location; + CAgnEntry *entry; + TBuf<GN_CALNOTE_MAX_LENGTH - 1> text; + TBuf<GN_CALNOTE_NUMBER_MAX_LENGTH - 1> phone_number; + TBuf<GN_CALNOTE_MAX_LENGTH - 1> mlocation; + TTime start_time, end_time, alarm_time; + TUint16 recurrence; + TUint8 type; + CAgnAppt *appt; + CAgnEvent *event; + CAgnAnniv *anniv; + const CAgnRptDef *rpt; + + g->InitCalendarL(); + + in >> location; + in.FinishL(); + + if ((entry = GetEntryL(location, false)) == NULL) { + out << TUint16(GNAPPLET_MSG_CALENDAR_NOTE_READ_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + return; + } + CleanupStack::PushL(entry); + + entry->RichTextL()->Extract(text, 0); + + switch (entry->Type()) { + case CAgnEntry::EAppt: + appt = entry->CastToAppt(); + type = GN_CALNOTE_MEETING; + start_time = appt->StartDateTime(); + end_time = appt->EndDateTime(); + mlocation = appt->Location(); + break; + + case CAgnEntry::EEvent: + event = entry->CastToEvent(); + type = GN_CALNOTE_REMINDER; + start_time = event->StartDate(); + end_time = event->EndDate(); + break; + + case CAgnEntry::EAnniv: + anniv = entry->CastToAnniv(); + type = GN_CALNOTE_BIRTHDAY; + start_time = anniv->StartDate(); + end_time = 0; + break; + + default: User::Leave(entry->Type()); + } + + if (entry->HasAlarm()) { + alarm_time = entry->AlarmInstanceDateTime(); + } else { + alarm_time = 0; + } + + if ((rpt = entry->RptDef()) != NULL) { + switch (rpt->Type()) { + case CAgnRptDef::EDaily: + recurrence = GN_CALNOTE_DAILY; + break; + case CAgnRptDef::EWeekly: + recurrence = (rpt->Interval() == 1) ? + GN_CALNOTE_WEEKLY : GN_CALNOTE_2WEEKLY; + break; + case CAgnRptDef::EMonthlyByDates: + case CAgnRptDef::EMonthlyByDays: + recurrence = GN_CALNOTE_MONTHLY; + break; + case CAgnRptDef::EYearlyByDate: + case CAgnRptDef::EYearlyByDay: + recurrence = GN_CALNOTE_YEARLY; + break; + default: + recurrence = GN_CALNOTE_NEVER; + break; + } + } else + recurrence = GN_CALNOTE_NEVER; + + out << TUint16(GNAPPLET_MSG_CALENDAR_NOTE_READ_RESP); + out << TUint16(GN_ERR_NONE); + out << location; + out << type; + out << toUTC(start_time); + out << toUTC(end_time); + out << toUTC(alarm_time); + out << text; + out << phone_number; + out << mlocation; + out << recurrence; + + CleanupStack::PopAndDestroy(entry); +} + + +static void WriteCalendarNoteL(PktBuf &in, PktBuf &out) +{ + TUint32 location; + CAgnEntry *entry; + TBuf<GN_CALNOTE_MAX_LENGTH - 1> text; + TBuf<GN_CALNOTE_NUMBER_MAX_LENGTH - 1> phone_number; + TBuf<GN_CALNOTE_MAX_LENGTH - 1> mlocation; + TTime start_time, end_time, alarm_time; + TUint16 recurrence; + TUint8 type; + CAgnAppt *appt; + CAgnEvent *event; + CAgnAnniv *anniv; + CAgnRptDef *rpt; + TAgnEntryId eid; + TAgnUniqueId uid; + TBool overwrite; + + g->InitCalendarL(); + + in >> location; + in >> type; + in >> start_time; + in >> end_time; + in >> alarm_time; + in >> text; + in >> phone_number; + in >> mlocation; + in >> recurrence; + in.FinishL(); + + if (location != 0) { + if ((entry = GetEntryL(location, false)) == NULL) { + out << TUint16(GNAPPLET_MSG_CALENDAR_NOTE_WRITE_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + return; + } + eid = entry->EntryId(); + uid = entry->UniqueId(); + delete entry; + overwrite = true; + } else { + overwrite = false; + } + + const CParaFormatLayer *paraFormatLayer = g->agendamodel->ParaFormatLayer(); + const CCharFormatLayer *charFormatLayer = g->agendamodel->CharFormatLayer(); + + switch (type) { + case GN_CALNOTE_MEETING: + appt = CAgnAppt::NewLC(paraFormatLayer, charFormatLayer); + if (toLOCAL(end_time).DateTime().Year() != 0) { + appt->SetStartAndEndDateTime(toLOCAL(start_time), toLOCAL(end_time)); + } else { + appt->SetStartAndEndDateTime(toLOCAL(start_time)); + } + appt->SetLocationL(mlocation); + entry = appt; + break; + case GN_CALNOTE_CALL: + appt = CAgnAppt::NewLC(paraFormatLayer, charFormatLayer); + if (toLOCAL(end_time).DateTime().Year() != 0) { + appt->SetStartAndEndDateTime(toLOCAL(start_time), toLOCAL(end_time)); + } else { + appt->SetStartAndEndDateTime(toLOCAL(start_time)); + } + appt->SetLocationL(phone_number); + entry = appt; + break; + case GN_CALNOTE_REMINDER: + event = CAgnEvent::NewLC(paraFormatLayer, charFormatLayer); + if (toLOCAL(end_time).DateTime().Year() != 0) { + event->SetStartAndEndDate(toLOCAL(start_time), toLOCAL(end_time)); + } else { + event->SetStartAndEndDate(toLOCAL(start_time)); + } + entry = event; + break; + case GN_CALNOTE_BIRTHDAY: + anniv = CAgnAnniv::NewLC(paraFormatLayer, charFormatLayer); + if (toLOCAL(end_time).DateTime().Year() != 0) { + anniv->SetStartAndEndDate(toLOCAL(start_time), toLOCAL(end_time)); + } else { + anniv->SetStartAndEndDate(toLOCAL(start_time)); + } + entry = anniv; + break; + default: + out << TUint16(GNAPPLET_MSG_CALENDAR_NOTE_WRITE_RESP); + out << TUint16(GN_ERR_UNKNOWN); + return; + } + + entry->RichTextL()->InsertL(0, text); + + if (toLOCAL(alarm_time).DateTime().Year() != 0) { + const TDateTime &d = toLOCAL(alarm_time).DateTime(); + entry->SetAlarm(alarm_time.DaysFrom(start_time), TTimeIntervalMinutes(d.Hour() * 60 + d.Minute())); + entry->SetHasAlarm(true); + } else { + entry->SetHasAlarm(false); + } + + if (recurrence != GN_CALNOTE_NEVER) { + rpt = CAgnRptDef::NewL(); + CleanupStack::PushL(rpt); + + if (recurrence == GN_CALNOTE_DAILY) { + TAgnDailyRpt daily; + rpt->SetDaily(daily); + rpt->SetInterval(1); + } else if (recurrence == GN_CALNOTE_WEEKLY) { + TAgnWeeklyRpt weekly; + weekly.ClearDays(); + weekly.SetDay(toLOCAL(start_time).DayNoInWeek()); + rpt->SetWeekly(weekly); + rpt->SetInterval(1); + } else if (recurrence == GN_CALNOTE_2WEEKLY) { + TAgnWeeklyRpt weekly; + weekly.ClearDays(); + weekly.SetDay(toLOCAL(start_time).DayNoInWeek()); + rpt->SetWeekly(weekly); + rpt->SetInterval(2); + } else if (recurrence == GN_CALNOTE_MONTHLY) { + TAgnMonthlyByDatesRpt monthly; + monthly.ClearAllDates(); + monthly.SetDate(toLOCAL(start_time).DayNoInMonth()); + rpt->SetMonthlyByDates(monthly); + rpt->SetInterval(1); + } else if (recurrence == GN_CALNOTE_YEARLY) { + TAgnYearlyByDateRpt yearly; + rpt->SetYearlyByDate(yearly); + rpt->SetInterval(1); + } + + rpt->SetStartDate(toLOCAL(start_time)); + rpt->SetRepeatForever(true); + entry->SetRptDefL(rpt); + CleanupStack::PopAndDestroy(rpt); + } + + if (overwrite) { + entry->SetId(eid); + entry->SetUniqueId(uid); + g->agendamodel->UpdateEntryL(entry); + } else { + g->agendamodel->AddEntryL(entry); + } + + out << TUint16(GNAPPLET_MSG_CALENDAR_NOTE_WRITE_RESP); + out << TUint16(GN_ERR_NONE); + out << location; + + CleanupStack::PopAndDestroy(entry); +} + + +static void DeleteCalendarNoteL(PktBuf &in, PktBuf &out) +{ + TUint32 location; + CAgnEntry *entry; + + g->InitCalendarL(); + + in >> location; + in.FinishL(); + + if ((entry = GetEntryL(location, false)) == NULL) { + out << TUint16(GNAPPLET_MSG_CALENDAR_NOTE_DELETE_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + return; + } + delete entry; + + g->agendamodel->DeleteEntryL(g->agendaserv->EntryIteratorPosition()); + + out << TUint16(GNAPPLET_MSG_CALENDAR_NOTE_DELETE_RESP); + out << TUint16(GN_ERR_NONE); + out << location; +} + + +static void ReadTodoL(PktBuf &in, PktBuf &out) +{ + TUint32 location; + CAgnEntry *entry; + TBuf<GN_TODO_MAX_LENGTH - 1> text; + CAgnTodo *todo; + + g->InitCalendarL(); + + in >> location; + in.FinishL(); + + if ((entry = GetEntryL(location, true)) == NULL) { + out << TUint16(GNAPPLET_MSG_CALENDAR_TODO_READ_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + return; + } + CleanupStack::PushL(entry); + + entry->RichTextL()->Extract(text, 0); + todo = entry->CastToTodo(); + + out << TUint16(GNAPPLET_MSG_CALENDAR_TODO_READ_RESP); + out << TUint16(GN_ERR_NONE); + out << location; + out << text; + out << TUint8(todo->Priority()); + + CleanupStack::PopAndDestroy(entry); +} + + +static void WriteTodoL(PktBuf &in, PktBuf &out) +{ + TUint32 location; + CAgnEntry *entry; + TBuf<GN_TODO_MAX_LENGTH - 1> text; + TUint8 priority; + CAgnTodo *todo; + TAgnEntryId eid; + TAgnUniqueId uid; + TBool overwrite; + CAgnTodoListNames *todolist; + + g->InitCalendarL(); + + in >> location; + in >> text; + in >> priority; + in.FinishL(); + + if (location != 0) { + if ((entry = GetEntryL(location, true)) == NULL) { + out << TUint16(GNAPPLET_MSG_CALENDAR_TODO_WRITE_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + return; + } + eid = entry->EntryId(); + uid = entry->UniqueId(); + delete entry; + overwrite = true; + } else { + overwrite = false; + } + + const CParaFormatLayer *paraFormatLayer = g->agendamodel->ParaFormatLayer(); + const CCharFormatLayer *charFormatLayer = g->agendamodel->CharFormatLayer(); + + todo = CAgnTodo::NewLC(paraFormatLayer, charFormatLayer); + + todolist = CAgnTodoListNames::NewL(); + CleanupStack::PushL(todolist); + g->agendamodel->PopulateTodoListNamesL(todolist); + + todo->RichTextL()->InsertL(0, text); + todo->SetPriority(priority); + todo->SetTodoListId(todolist->TodoListId(0)); + + if (overwrite) { + todo->SetId(eid); + todo->SetUniqueId(uid); + g->agendamodel->UpdateEntryL(todo); + } else { + g->agendamodel->AddEntryL(todo); + } + + out << TUint16(GNAPPLET_MSG_CALENDAR_TODO_WRITE_RESP); + out << TUint16(GN_ERR_NONE); + out << location; + + CleanupStack::PopAndDestroy(todolist); + CleanupStack::PopAndDestroy(todo); +} + + +static void DeleteTodoL(PktBuf &in, PktBuf &out) +{ + TUint32 location; + CAgnEntry *entry; + + g->InitCalendarL(); + + in >> location; + in.FinishL(); + + if ((entry = GetEntryL(location, true)) == NULL) { + out << TUint16(GNAPPLET_MSG_CALENDAR_TODO_DELETE_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + return; + } + delete entry; + + g->agendamodel->DeleteEntryL(g->agendaserv->EntryIteratorPosition()); + + out << TUint16(GNAPPLET_MSG_CALENDAR_TODO_DELETE_RESP); + out << TUint16(GN_ERR_NONE); + out << location; +} + + +void HandleCalendarMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + + in >> code; + switch (code) { + case GNAPPLET_MSG_CALENDAR_NOTE_READ_REQ: + ReadCalendarNoteL(in, out); + break; + + case GNAPPLET_MSG_CALENDAR_NOTE_WRITE_REQ: + WriteCalendarNoteL(in, out); + break; + + case GNAPPLET_MSG_CALENDAR_NOTE_DELETE_REQ: + DeleteCalendarNoteL(in, out); + break; + + case GNAPPLET_MSG_CALENDAR_TODO_READ_REQ: + ReadTodoL(in, out); + break; + + case GNAPPLET_MSG_CALENDAR_TODO_WRITE_REQ: + WriteTodoL(in, out); + break; + + case GNAPPLET_MSG_CALENDAR_TODO_DELETE_REQ: + DeleteTodoL(in, out); + break; + + default: + out << TUint16((code + 1) & ~1); + out << TUint16(GN_ERR_NOTSUPPORTED); + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_clock.cpp b/contrib/symbian/gnapplet/proto_clock.cpp new file mode 100644 index 0000000..e9a95c4 --- /dev/null +++ b/contrib/symbian/gnapplet/proto_clock.cpp @@ -0,0 +1,144 @@ +/* + * $Id: proto_clock.cpp,v 1.1 2004/10/11 20:29:43 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the clock and alarm message handler. + * + */ + +#include "proto.h" + + +static void ReadClockL(PktBuf &in, PktBuf &out) +{ + TTime t; + + in.FinishL(); + + t.UniversalTime(); + + out << (TUint16)GNAPPLET_MSG_CLOCK_DATETIME_READ_RESP; + out << (TUint16)GN_ERR_NONE; + out << t; +} + + +static void WriteClockL(PktBuf &in, PktBuf &out) +{ + TTime t; + + in >> t; + in.FinishL(); + + if (User::SetHomeTime(toLOCAL(t)) != KErrNone) { + out << (TUint16)GNAPPLET_MSG_CLOCK_DATETIME_WRITE_RESP; + out << (TUint16)GN_ERR_FAILED; + return; + } + + out << (TUint16)GNAPPLET_MSG_CLOCK_DATETIME_WRITE_RESP; + out << (TUint16)GN_ERR_NONE; +} + + +static void ReadAlarmL(PktBuf &in, PktBuf &out) +{ + TAlarmInfo info; + TBool enabled; + + g->InitClockL(); + + in.FinishL(); + + enabled = false; + while (g->alarmserv->AlarmInfo(info, RAlarmServer::EInfoNext) == KErrNone) { + if (info.iType == EAlarmTypeClock) { + enabled = true; + break; + } + } + + out << (TUint16)GNAPPLET_MSG_CLOCK_ALARM_READ_RESP; + out << (TUint16)GN_ERR_NONE; + out << enabled; + out << (enabled ? toUTC(info.iAlarmTime) : TTime(0)); +} + + +static void WriteAlarmL(PktBuf &in, PktBuf &out) +{ + TAlarmInfo info; + TBool enabled; + TTime alarm; + + g->InitClockL(); + + in >> enabled; + in >> alarm; + in.FinishL(); + + if (enabled) { + g->alarmserv->SetClockAlarm(0, toLOCAL(alarm), _L(""), _L("a"), EAlarmClockNext24hours); + } else { + while (g->alarmserv->AlarmInfo(info, RAlarmServer::EInfoNext) == KErrNone) { + if (info.iType == EAlarmTypeClock) { + g->alarmserv->AlarmDelete(info.iAlarmId); + break; + } + } + } + + out << (TUint16)GNAPPLET_MSG_CLOCK_ALARM_WRITE_RESP; + out << (TUint16)GN_ERR_NONE; +} + + +void HandleClockMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + + in >> code; + switch (code) { + case GNAPPLET_MSG_CLOCK_DATETIME_READ_REQ: + ReadClockL(in, out); + break; + + case GNAPPLET_MSG_CLOCK_DATETIME_WRITE_REQ: + WriteClockL(in, out); + break; + + case GNAPPLET_MSG_CLOCK_ALARM_READ_REQ: + ReadAlarmL(in, out); + break; + + case GNAPPLET_MSG_CLOCK_ALARM_WRITE_REQ: + WriteAlarmL(in, out); + break; + + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_debug.cpp b/contrib/symbian/gnapplet/proto_debug.cpp new file mode 100644 index 0000000..808e475 --- /dev/null +++ b/contrib/symbian/gnapplet/proto_debug.cpp @@ -0,0 +1,68 @@ +/* + * $Id: proto_debug.cpp,v 1.1 2004/04/12 11:30:04 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the debugging message handler. + * + */ + +#include "proto.h" + + +void Debug(TRefByValue<const TDesC> fmt, ...) +{ + TBuf8<1100> buf; + TBuf<512> msg; + PktBuf pkt; + VA_LIST ap; + + VA_START(ap, fmt); + msg.FormatList(fmt, ap); + VA_END(ap); + + buf.Zero(); + pkt.Set(buf.Ptr(), 1100); + + pkt << (TUint16)GNAPPLET_MSG_DEBUG_NOTIFICATION; + pkt << (TUint16)GN_ERR_NONE; + pkt << msg; + + buf.SetLength(pkt.GetOffs()); + WritePacketL(g->current_device, GNAPPLET_MSG_DEBUG, buf); +} + + +void HandleDebugMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + + in >> code; + switch (code) { + + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_info.cpp b/contrib/symbian/gnapplet/proto_info.cpp new file mode 100644 index 0000000..30dc0b6 --- /dev/null +++ b/contrib/symbian/gnapplet/proto_info.cpp @@ -0,0 +1,92 @@ +/* + * $Id: proto_info.cpp,v 1.5 2004/04/12 12:55:05 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the phone info message handler. + * + */ + +#include "proto.h" + +#include <sysutil.h> +#include <hal.h> +#include <hal_data.h> + + +void HandleInfoMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + MBasicGsmPhoneId::TId id; + TBuf<KSysUtilVersionTextLength> v; + TPtrC model, sw_ver; + TBuf<32> hw_ver; + TInt i, s, manuf; + + in >> code; + switch (code) { + case GNAPPLET_MSG_INFO_ID_REQ: + g->InitPhoneInfoL(); + User::LeaveIfError(g->phone->GetGsmPhoneId(id)); + SysUtil::GetSWVersion(v); + User::LeaveIfError(HAL::Get(HALData::EManufacturer, manuf)); + Debug(_L("sw version:\n%S"), &v); + for (s = 0; v[s] < '0' || v[s] > '9'; s++) ; + for (i = s + 1; v[i] != '\n'; i++) ; + sw_ver.Set(v.Ptr() + s, i - s); + if (manuf == HALData::EManufacturer_Nokia) { + for (s = i + 1; v[s] != '\n'; s++) ; + for (i = ++s; v[i] != '\n'; i++) ; + model.Set(v.Ptr() + s, i - s); + } else { + model.Set(id.iModelId); + } + /* + User::LeaveIfError(HAL::Get(HALData::EDeviceFamily, i)); + hw_ver.AppendNum(i); + hw_ver.Append(_L("/")); + User::LeaveIfError(HAL::Get(HALData::EDeviceFamilyRev, i)); + hw_ver.AppendNum(i); + hw_ver.Append(_L("/")); + */ + User::LeaveIfError(HAL::Get(HALData::EManufacturerHardwareRev, i)); + hw_ver.AppendNum(i); + + out << (TUint16)GNAPPLET_MSG_INFO_ID_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint16)GNAPPLET_MAJOR_VERSION; + out << (TUint16)GNAPPLET_MINOR_VERSION; + out << id.iManufacturerId; + out << model; + out << id.iSerialNumber; + out << sw_ver; + out << hw_ver; + in.FinishL(); + break; + + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_netinfo.cpp b/contrib/symbian/gnapplet/proto_netinfo.cpp new file mode 100644 index 0000000..68119b0 --- /dev/null +++ b/contrib/symbian/gnapplet/proto_netinfo.cpp @@ -0,0 +1,102 @@ +/* + * $Id: proto_netinfo.cpp,v 1.1 2004/04/08 23:29:06 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the network status message handler. + * + */ + +#include "proto.h" + + +static void NetinfoGetCurrentReqL(PktBuf &in, PktBuf &out) +{ + MBasicGsmPhoneNetwork::TCurrentNetworkInfo net_info; + TBuf<8> net_code; + + g->InitPhoneInfoL(); + + User::LeaveIfError(g->phone->GetCurrentNetworkInfo(net_info)); + net_code.Format(_L("%03d %02d"), net_info.iNetworkInfo.iId.iMCC, net_info.iNetworkInfo.iId.iMNC); + + out << (TUint16)GNAPPLET_MSG_NETINFO_GETCURRENT_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint16)net_info.iCellId; + out << (TUint16)net_info.iLocationAreaCode; + out << (TUint8)0; // FIXME: registration status + out << net_code; +} + + +static void NetinfoGetRFLevelReqL(PktBuf &in, PktBuf &out) +{ + TUint8 percent; + + g->InitPhoneInfoL(); + + switch (g->sysagent->GetState(KUidNetworkStrength)) { + case ESANetworkStrengthLow: + percent = 33; + break; + case ESANetworkStrengthMedium: + percent = 66; + break; + case ESANetworkStrengthHigh: + percent = 100; + break; + case ESANetworkStrengthNone: + case ESANetworkStrengthUnknown: + default: + percent = 0; + break; + } + + out << (TUint16)GNAPPLET_MSG_NETINFO_GETRFLEVEL_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint8)percent; +} + + +void HandleNetinfoMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + + in >> code; + switch (code) { + case GNAPPLET_MSG_NETINFO_GETCURRENT_REQ: + in.FinishL(); + NetinfoGetCurrentReqL(in, out); + break; + + case GNAPPLET_MSG_NETINFO_GETRFLEVEL_REQ: + in.FinishL(); + NetinfoGetRFLevelReqL(in, out); + break; + + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_phonebook.cpp b/contrib/symbian/gnapplet/proto_phonebook.cpp new file mode 100644 index 0000000..8c4099b --- /dev/null +++ b/contrib/symbian/gnapplet/proto_phonebook.cpp @@ -0,0 +1,695 @@ +/* + * $Id: proto_phonebook.cpp,v 1.8 2004/09/13 22:08:54 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * Copyright (C) 2007 Matthias Lechner <matthias@lmme.de> + * + * This file contains the phonebook message handler. + * + */ + +#include "proto.h" +_LIT(KTsyName,"phonetsy.tsy"); + + +static void LogFilterL(TUint16 memtype) +{ + CLogFilter *filter; + TLogString direction; + TRequestStatus status; + + filter = CLogFilter::NewL(); + CleanupStack::PushL(filter); + switch (memtype) { + case GN_MT_DC: // dialled calls + User::LeaveIfError(g->logclient->GetString(direction, R_LOG_DIR_OUT)); + break; + case GN_MT_RC: // received calls + User::LeaveIfError(g->logclient->GetString(direction, R_LOG_DIR_IN)); + break; + case GN_MT_MC: // missed calls + User::LeaveIfError(g->logclient->GetString(direction, R_LOG_DIR_MISSED)); + break; + default: + User::Invariant(); + } + filter->SetDirection(direction); + + WaitIfReqL(g->logview->SetFilterL(*filter, status), status); + CleanupStack::PopAndDestroy(filter); +} + + +static void PhonebookReadNextReqL(TUint16 memtype, PktBuf &in, PktBuf &out) +{ + TUint16 ns; + CContactItem *item; + TBuf<64> family_name, given_name, name; + TContactItemId location; + int i, n; + TUint16 start; + + g->InitPhoneBookL(); + in >> start; + in.FinishL(); + + if( start == 1 ) + g->contactIter->Reset(); + + location = g->contactIter->NextL(); + if( location == KNullContactId ) { + cons->Printf(_L("eof\n")); + g->contactIter->Reset(); + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READNEXT_RESP; + out << (TUint16)GN_ERR_EMPTYLOCATION; + } + + TRAPD(error, item = g->cdb->ReadContactL(location)); + if (error != KErrNone) { + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READNEXT_RESP; + out << (TUint16)GN_ERR_EMPTYLOCATION; + return; + } + cons->Printf(_L("read: %d\n"), location); + + CleanupStack::PushL(item); + CContactItemFieldSet &fieldset = item->CardFields(); + n = fieldset.Count(); + ns = 1; + + for (i = 0; i < n; i++) { + const CContactItemField &field = fieldset[i]; + + if (field.StorageType() == KStorageTypeText && field.TextStorage()->Text().Length() <= 0) { + continue; + } + + if (field.ContentType().ContainsFieldType(KUidContactFieldGivenName)) { + given_name.Copy(field.TextStorage()->Text()); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldFamilyName)) { + family_name.Copy(field.TextStorage()->Text()); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldFax)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldPhoneNumber)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldEMail)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldNote)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldRingTone)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldUrl)) { + ns++; + } + } + if (family_name.Length() > 0 && given_name.Length() > 0) { + name.Copy(family_name); + name.Append(_L(" ")); + name.Append(given_name); + } else if (family_name.Length() > 0) { + name.Copy(family_name); + } else { + name.Copy(given_name); + } + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READNEXT_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint16) location; + out << ns; + out << (TUint16)GN_PHONEBOOK_ENTRY_Name << (TUint16)0 << name; + for (i = 0; i < n; i++) { + const CContactItemField &field = fieldset[i]; + + if (field.StorageType() == KStorageTypeText && field.TextStorage()->Text().Length() <= 0) { + continue; + } + + if (field.ContentType().ContainsFieldType(KUidContactFieldFax)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Number << (TUint16)GN_PHONEBOOK_NUMBER_Fax << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldPhoneNumber)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Number; + if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapFAX)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Fax; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapHOME)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Home; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapWORK)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Work; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapCELL)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Mobile; + } else { + out << (TUint16)GN_PHONEBOOK_NUMBER_General; + } + out << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldEMail)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Email << (TUint16)0 << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldNote)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Note << (TUint16)0 << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldRingTone)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Ringtone << (TUint16)0 << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldUrl)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_URL << (TUint16)0 << field.TextStorage()->Text(); + } + } + CleanupStack::PopAndDestroy(item); +} + +static void PhonebookReadReqL(TUint16 memtype, PktBuf &in, PktBuf &out) +{ + TUint16 ns; + TUint32 location; + CContactItem *item; + TBuf<64> family_name, given_name, name; + int i, n; + + g->InitPhoneBookL(); + + in >> location; + in.FinishL(); + + TRAPD(error, item = g->cdb->ReadContactL(location)); + if (error != KErrNone) { + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READ_RESP; + out << (TUint16)GN_ERR_EMPTYLOCATION; + return; + } + cons->Printf(_L("read: %d\n"), location); + + CleanupStack::PushL(item); + CContactItemFieldSet &fieldset = item->CardFields(); + n = fieldset.Count(); + ns = 1; + + for (i = 0; i < n; i++) { + const CContactItemField &field = fieldset[i]; + + if (field.StorageType() == KStorageTypeText && field.TextStorage()->Text().Length() <= 0) { + continue; + } + + if (field.ContentType().ContainsFieldType(KUidContactFieldGivenName)) { + given_name.Copy(field.TextStorage()->Text()); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldFamilyName)) { + family_name.Copy(field.TextStorage()->Text()); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldFax)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldPhoneNumber)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldEMail)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldNote)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldRingTone)) { + ns++; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldUrl)) { + ns++; + } + } + if (family_name.Length() > 0 && given_name.Length() > 0) { + name.Copy(family_name); + name.Append(_L(" ")); + name.Append(given_name); + } else if (family_name.Length() > 0) { + name.Copy(family_name); + } else { + name.Copy(given_name); + } + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READ_RESP; + out << (TUint16)GN_ERR_NONE; + out << ns; + out << (TUint16)GN_PHONEBOOK_ENTRY_Name << (TUint16)0 << name; + for (i = 0; i < n; i++) { + const CContactItemField &field = fieldset[i]; + + if (field.StorageType() == KStorageTypeText && field.TextStorage()->Text().Length() <= 0) { + continue; + } + + if (field.ContentType().ContainsFieldType(KUidContactFieldFax)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Number << (TUint16)GN_PHONEBOOK_NUMBER_Fax << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldPhoneNumber)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Number; + if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapFAX)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Fax; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapHOME)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Home; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapWORK)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Work; + } else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapCELL)) { + out << (TUint16)GN_PHONEBOOK_NUMBER_Mobile; + } else { + out << (TUint16)GN_PHONEBOOK_NUMBER_General; + } + out << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldEMail)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Email << (TUint16)0 << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldNote)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Note << (TUint16)0 << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldRingTone)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_Ringtone << (TUint16)0 << field.TextStorage()->Text(); + } else if (field.ContentType().ContainsFieldType(KUidContactFieldUrl)) { + out << (TUint16)GN_PHONEBOOK_ENTRY_URL << (TUint16)0 << field.TextStorage()->Text(); + } + } + CleanupStack::PopAndDestroy(item); +} + + +static void PhonebookWriteReqL(PktBuf &in, PktBuf &out) +{ + TUint16 memtype, ns, type, subtype; + TUint32 location; + CContactItem *item; + CContactItemFieldSet *fieldset; + CContactItemField *field; + TBuf<64> name; + TPtrC family_name, given_name; + int i, s; + + g->InitPhoneBookL(); + + in >> memtype; + in >> location; + + if (memtype != GN_MT_ME) { + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_WRITE_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + return; + } + + fieldset = CContactItemFieldSet::NewLC(); + in >> ns; + for (i = 0; i < ns; i++) { + in >> type >> subtype >> name; + switch (type) { + case GN_PHONEBOOK_ENTRY_Name: + for (s = 0; s < name.Length() && name[s] != ' '; s++) ; + if (s >= 1 && s < name.Length()) { + family_name.Set(name.Ptr(), s); + given_name.Set(name.Ptr() + s + 1, name.Length() - s - 1); + } else { + family_name.Set(name); + } + if (family_name.Length() > 0) { + field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldFamilyName); + //field->SetLabelL(_L("alma")); + field->SetMapping(KUidContactFieldVCardMapUnusedN); + field->TextStorage()->SetTextL(family_name); + fieldset->AddL(*field); + } + if (given_name.Length() > 0) { + field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldGivenName); + //field->SetLabelL(_L("alma")); + field->SetMapping(KUidContactFieldVCardMapUnusedN); + field->TextStorage()->SetTextL(given_name); + fieldset->AddL(*field); + } + break; + case GN_PHONEBOOK_ENTRY_Email: + field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldEMail); + field->SetMapping(KUidContactFieldVCardMapEMAILINTERNET); + field->TextStorage()->SetTextL(name); + fieldset->AddL(*field); + break; + case GN_PHONEBOOK_ENTRY_Note: + field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldNote); + field->SetMapping(KUidContactFieldVCardMapNOTE); + field->TextStorage()->SetTextL(name); + fieldset->AddL(*field); + break; + case GN_PHONEBOOK_ENTRY_Number: + if (subtype == GN_PHONEBOOK_NUMBER_Fax) { + field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldFax); + field->SetMapping(KUidContactFieldVCardMapTEL); + field->AddFieldTypeL(KUidContactFieldVCardMapFAX); + } else { + field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldPhoneNumber); + field->SetMapping(KUidContactFieldVCardMapTEL); + switch (subtype) { + case GN_PHONEBOOK_NUMBER_Home: + field->AddFieldTypeL(KUidContactFieldVCardMapHOME); + break; + case GN_PHONEBOOK_NUMBER_Mobile: + field->AddFieldTypeL(KUidContactFieldVCardMapCELL); + break; + case GN_PHONEBOOK_NUMBER_Work: + field->AddFieldTypeL(KUidContactFieldVCardMapWORK); + break; + } + } + field->TextStorage()->SetTextL(name); + fieldset->AddL(*field); + break; + case GN_PHONEBOOK_ENTRY_Ringtone: + //field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldRingTone); + //field->TextStorage()->SetTextL(name); + //fieldset->AddL(*field); + break; + case GN_PHONEBOOK_ENTRY_Group: + //field = CContactItemField::NewL(KStorageTypeText, + //field->TextStorage()->SetTextL(name); + //fieldset->AddL(*field); + break; + case GN_PHONEBOOK_ENTRY_URL: + field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldUrl); + field->SetMapping(KUidContactFieldVCardMapURL); + field->TextStorage()->SetTextL(name); + fieldset->AddL(*field); + break; + default: + break; + } + } + in.FinishL(); + + TRAPD(error, item = g->cdb->OpenContactL(location)); + if (error == KErrNone) { + item->UpdateFieldSet(fieldset); + CleanupStack::Pop(fieldset); + CleanupStack::PushL(item); + g->cdb->CommitContactL(*item); + } else { + item = CContactCard::NewL(); + item->UpdateFieldSet(fieldset); + CleanupStack::Pop(fieldset); + CleanupStack::PushL(item); + location = g->cdb->AddNewContactL(*item); + } + CleanupStack::Pop(item); + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_WRITE_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; + out << location; + cons->Printf(_L("write: %d\n"), location); +} + + +static void PhonebookDeleteReqL(TUint16 memtype, PktBuf &in, PktBuf &out) +{ + TUint32 location; + + g->InitPhoneBookL(); + + in >> location; + in.FinishL(); + + TRAPD(error, g->cdb->DeleteContactL(location)); + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_DELETE_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; + out << location; +} + + +static void PhonebookStatusReqL(TUint16 memtype, PktBuf &in, PktBuf &out) +{ + TUint32 used, free; + + g->InitPhoneBookL(); + + used = g->cdb->CountL(); + //free = 0x7fffffff - used; + free = 0x10000 - used; //FIXME: better limit + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_STATUS_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; + out << used; + out << free; +} + + +static void LogReadReqL(TUint16 memtype, PktBuf &in, PktBuf &out) +{ + TUint32 location; + TRequestStatus status; + + g->InitLogClientL(); + + in >> location; + in.FinishL(); + + cons->Printf(_L("log(%d) read: %d\n"), (int)memtype, location); + + LogFilterL(memtype); + if (location < 1 || location > static_cast<TUint32>(g->logview->CountL())) { + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READ_RESP; + out << (TUint16)GN_ERR_EMPTYLOCATION; + return; + } + + WaitIfReqL(g->logview->FirstL(status), status); + while (--location > 0) { + WaitIfReqL(g->logview->NextL(status), status); + } + const CLogEvent &event = g->logview->Event(); + + cons->Printf(_L("c: %d, n: %S\n"), (int)event.Contact(), &event.Number()); + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READ_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint16)3; + + out << (TUint16)GN_PHONEBOOK_ENTRY_Name; + out << (TUint16)0; + out << _L(""); + + out << (TUint16)GN_PHONEBOOK_ENTRY_Number; + out << (TUint16)GN_PHONEBOOK_NUMBER_General; + out << event.Number(); + + out << (TUint16)GN_PHONEBOOK_ENTRY_Date; + out << (TUint16)0; + out << event.Time(); +} + + +static void LogDeleteReqL(TUint16 memtype, PktBuf &in, PktBuf &out) +{ + TUint32 i, location; + TRequestStatus status; + + g->InitLogClientL(); + + in >> location; + in.FinishL(); + + LogFilterL(memtype); + if (location < 1 || location > static_cast<TUint32>(g->logview->CountL())) { + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_DELETE_RESP; + out << (TUint16)GN_ERR_EMPTYLOCATION; + return; + } + + WaitIfReqL(g->logview->FirstL(status), status); + for (i = 1; i < location; i++) { + WaitIfReqL(g->logview->NextL(status), status); + } + g->logclient->DeleteEvent(g->logview->Event().Id(), status); + WaitIfReqL(true, status); + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_DELETE_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; + out << location; +} + + +static void LogStatusReqL(TUint16 memtype, PktBuf &in, PktBuf &out) +{ + TUint32 used, free; + + g->InitLogClientL(); + + LogFilterL(memtype); + + used = g->logview->CountL(); + free = 0; + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_STATUS_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; + out << used; + out << free; +} + + +static void DialNumberL(PktBuf &in, PktBuf &out) { + /// @todo maybe use a CActive object to allow the call to be cancelled from gammu + TBuf<100> aPhoneNumber; + + in >> aPhoneNumber; + + cons->Printf( _L("dialing... number:\n") ); + cons->Printf( aPhoneNumber ); + cons->Printf( _L("\n") ); + + TName newCallName = _L("call"); + + //Create a connection to the tel server + RTelServer server; + CleanupClosePushL(server); + User::LeaveIfError(server.Connect()); + + //Load in the phone device driver + User::LeaveIfError(server.LoadPhoneModule(KTsyName)); + + //Find the number of phones available from the tel server + TInt numberPhones; + User::LeaveIfError(server.EnumeratePhones(numberPhones)); + + //Check there are available phones + if (numberPhones < 1) + { + User::Leave(KErrNotFound); + } + + //Get info about the first available phone + RTelServer::TPhoneInfo info; + User::LeaveIfError(server.GetPhoneInfo(0, info)); + + //Use this info to open a connection to the phone, the phone is identified by its name + RPhone phone; + CleanupClosePushL(phone); + User::LeaveIfError(phone.Open(server, info.iName)); + + //Get info about the first line from the phone + RPhone::TLineInfo lineInfo; + User::LeaveIfError(phone.GetLineInfo(0, lineInfo)); + + //Use this to open a line + RLine line; + CleanupClosePushL(line); + User::LeaveIfError(line.Open(phone, lineInfo.iName)); + + //Open a new call on this line + RCall call; + CleanupClosePushL(call); + User::LeaveIfError(call.OpenNewCall(line, newCallName)); + + if ((call.Dial(aPhoneNumber) == KErrNone)) + { + TRequestStatus iStatus; + RCall::TStatus iLineStatus; + line.NotifyStatusChange(iStatus, iLineStatus); + User::WaitForRequest(iStatus); + } + + CleanupStack::PopAndDestroy(4);//phone, line, call + + //Unload the phone device driver + User::LeaveIfError(server.UnloadPhoneModule(KTsyName)); + + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_DIAL_RESP; + out << (TUint16)GN_ERR_NONE; +} + + +void HandlePhonebookMsg(PktBuf &in, PktBuf &out) { + TUint16 code, memtype; + + in >> code; + switch (code) { + case GNAPPLET_MSG_PHONEBOOK_READ_REQ: + in >> memtype; + switch (memtype) { + case GN_MT_ME: + PhonebookReadReqL(memtype, in, out); + break; + case GN_MT_DC: + case GN_MT_RC: + case GN_MT_MC: + LogReadReqL(memtype, in, out); + break; + default: + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READ_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + break; + } + break; + + case GNAPPLET_MSG_PHONEBOOK_WRITE_REQ: + PhonebookWriteReqL(in, out); + break; + + case GNAPPLET_MSG_PHONEBOOK_DELETE_REQ: + in >> memtype; + switch (memtype) { + case GN_MT_ME: + PhonebookDeleteReqL(memtype, in, out); + break; + case GN_MT_DC: + case GN_MT_RC: + case GN_MT_MC: + LogDeleteReqL(memtype, in, out); + break; + default: + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_DELETE_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + break; + } + break; + + case GNAPPLET_MSG_PHONEBOOK_STATUS_REQ: + in >> memtype; + in.FinishL(); + switch (memtype) { + case GN_MT_ME: + PhonebookStatusReqL(memtype, in, out); + break; + case GN_MT_DC: + case GN_MT_RC: + case GN_MT_MC: + LogStatusReqL(memtype, in, out); + break; + default: + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_STATUS_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + break; + } + break; + + case GNAPPLET_MSG_PHONEBOOK_DIAL_REQ: + DialNumberL(in, out); + break; + + case GNAPPLET_MSG_PHONEBOOK_READNEXT_REQ: + in >> memtype; + switch (memtype) { + case GN_MT_ME: + PhonebookReadNextReqL(memtype, in, out); + break; + default: + out << (TUint16)GNAPPLET_MSG_PHONEBOOK_READNEXT_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + } + break; + + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_power.cpp b/contrib/symbian/gnapplet/proto_power.cpp new file mode 100644 index 0000000..b2151cc --- /dev/null +++ b/contrib/symbian/gnapplet/proto_power.cpp @@ -0,0 +1,77 @@ +/* + * $Id: proto_power.cpp,v 1.1 2004/04/08 23:29:06 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the power status message handler. + * + */ + +#include "proto.h" + + +static void PowerInfoReqL(PktBuf &in, PktBuf &out) +{ + MBasicGsmPhoneBatteryAndPower::TBatteryInfo batt_info; + TUint8 percent, source; + + g->InitPhoneInfoL(); + + User::LeaveIfError(g->phone->GetBatteryInfo(batt_info)); + percent = batt_info.iChargeLevel; + switch (batt_info.iStatus) { + case MBasicGsmPhoneBatteryAndPower::EPoweredByBattery: + source = GN_PS_BATTERY; + break; + case MBasicGsmPhoneBatteryAndPower::EBatteryConnectedButExternallyPowered: + case MBasicGsmPhoneBatteryAndPower::ENoBatteryConnected: + case MBasicGsmPhoneBatteryAndPower::EPowerFault: + default: + source = GN_PS_ACDC; + break; + } + + out << (TUint16)GNAPPLET_MSG_POWER_INFO_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint8)percent; + out << (TUint8)source; +} + + +void HandlePowerMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + + in >> code; + switch (code) { + case GNAPPLET_MSG_POWER_INFO_REQ: + in.FinishL(); + PowerInfoReqL(in, out); + break; + + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_profile.cpp b/contrib/symbian/gnapplet/proto_profile.cpp new file mode 100644 index 0000000..515dc13 --- /dev/null +++ b/contrib/symbian/gnapplet/proto_profile.cpp @@ -0,0 +1,170 @@ +/* + * $Id: proto_profile.cpp,v 1.2 2005/03/24 00:08:12 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file contains the profile message handler. + * + */ + +#include "proto.h" + + +static void ReadProfileL(PktBuf &in, PktBuf &out) +{ + TUint16 id; + TBuf<256> ringtone1, ringtone2; + int call_alert, volume, vibra, key_tone, i; + + g->InitProfileL(); + + in >> id; + in.FinishL(); + + if (id >= 5) { + out << (TUint16)GNAPPLET_MSG_PROFILE_READ_RESP; + out << (TUint16)GN_ERR_INVALIDLOCATION; + return; + } + + int i5; + CArrayFixFlat<TContactItemId> *foo = new (ELeave)CArrayFixFlat<long>(10); + g->profile->GetProfileMultiData(ringtone1, ringtone2, call_alert, volume, vibra, key_tone, foo, i5, id); + delete foo; + //Debug(_L("%S|%S|%d|%d|%d|%d|%d"), &ringtone1, &ringtone2, call_alert, volume, vibra, key_tone, i5); + + CPermanentFileStore *fstore = CPermanentFileStore::OpenLC( + *g->profilefs, + _L("c:\\system\\Apps\\profileApp\\dbProfile.db"), + EFileRead | EFileWrite); + RDbStoreDatabase database; + database.OpenL(fstore, fstore->Root()); + RDbTable table; + // tableId, profileName, profileUID, remove, modify, active, visible, rename + table.Open(database, _L("ProfileLookup")); + table.FirstL(); + for (i = 0; i < id; i++) + table.NextL(); + table.GetL(); + TBuf<16> name = table.ColDes16(2); + table.Close(); + database.Close(); + CleanupStack::PopAndDestroy(fstore); + + out << (TUint16)GNAPPLET_MSG_PROFILE_READ_RESP; + out << (TUint16)GN_ERR_NONE; + out << id; + if (name.Length() == 0 || name == _L(" ")) { + switch (id) { + case 0: out << _L("General"); break; + case 1: out << _L("Silent"); break; + case 2: out << _L("Meeting"); break; + case 3: out << _L("Outdoor"); break; + case 4: out << _L("Pager"); break; + } + out << (TUint16)id; + } else { + out << name; + out << (TUint16)0xffff; + } + switch (key_tone) { + case 0x00: out << (TUint8)GN_PROFILE_KEYVOL_Off; break; + case 0x01: out << (TUint8)GN_PROFILE_KEYVOL_Level1; break; + case 0x02: out << (TUint8)GN_PROFILE_KEYVOL_Level2; break; + case 0x03: out << (TUint8)GN_PROFILE_KEYVOL_Level3; break; + default: User::Leave(1); + } + // lights + switch (call_alert) { + case 0x00: out << (TUint8)GN_PROFILE_CALLALERT_Ringing; break; + case 0x01: out << (TUint8)GN_PROFILE_CALLALERT_Ascending; break; + case 0x02: out << (TUint8)GN_PROFILE_CALLALERT_RingOnce; break; + case 0x03: out << (TUint8)GN_PROFILE_CALLALERT_BeepOnce; break; + case 0x04: out << (TUint8)GN_PROFILE_CALLALERT_Off; break; + default: User::Leave(1); + } + //out << ringtone; // ringtone + out << (TUint8)volume; + // message tone FIXME: mar nem enum!!! + out << (TUint8)GN_PROFILE_WARNING_On; // warning tone + out << (TUint8)(vibra ? GN_PROFILE_VIBRATION_On : GN_PROFILE_VIBRATION_Off); + // caller groups + // automatic answer +} + + +static void GetActiveProfileL(PktBuf &in, PktBuf &out) +{ + int id; + + g->InitProfileL(); + + in.FinishL(); + + CPermanentFileStore *fstore = CPermanentFileStore::OpenLC( + *g->profilefs, + _L("c:\\system\\Apps\\profileApp\\dbProfile.db"), + EFileRead | EFileWrite); + RDbStoreDatabase database; + database.OpenL(fstore, fstore->Root()); + RDbTable table; + // tableId, profileName, profileUID, remove, modify, active, visible, rename + table.Open(database, _L("ProfileLookup")); + table.FirstL(); + for (id = 0; table.AtRow(); id++) { + table.GetL(); + if (table.ColInt(6) != 0) break; + table.NextL(); + } + table.Close(); + database.Close(); + CleanupStack::PopAndDestroy(fstore); + + out << (TUint16)GNAPPLET_MSG_PROFILE_GET_ACTIVE_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint16)id; +} + + +void HandleProfileMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + + in >> code; + switch (code) { + case GNAPPLET_MSG_PROFILE_READ_REQ: + ReadProfileL(in, out); + break; + + case GNAPPLET_MSG_PROFILE_GET_ACTIVE_REQ: + GetActiveProfileL(in, out); + break; + + case GNAPPLET_MSG_PROFILE_WRITE_REQ: + case GNAPPLET_MSG_PROFILE_SET_ACTIVE_REQ: + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/proto_sms.cpp b/contrib/symbian/gnapplet/proto_sms.cpp new file mode 100644 index 0000000..8c836b1 --- /dev/null +++ b/contrib/symbian/gnapplet/proto_sms.cpp @@ -0,0 +1,774 @@ +/* + * $Id: proto_sms.cpp,v 1.5 2004/07/11 22:53:22 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * Copyright (C) 2007 Matthias Lechner <matthias@lmme.de> + * + * This file contains the SMS message handler. + * + */ + +#include "proto.h" + +const TMsvId MyFolders = 0x1008; +const TMsvId Templates = 0x1009; + +class SMSObserver: public MMsvSessionObserver { +public: + SMSObserver(void); + int folder_count; + TMsvId folders[GN_MT_XX]; + void RefreshL(void); + TUint16 GetMT(TMsvId id); + +private: + int next_folder; + void FetchL(void); + + virtual void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,TAny* aArg2, TAny* aArg3); +}; + + +SMSObserver sms_observer; + + +SMSObserver::SMSObserver(void) +{ + next_folder = 0; + folder_count = 0; +} + + +void SMSObserver::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1,TAny* aArg2, TAny* aArg3) +{ +} + + +void SMSObserver::FetchL(void) +{ + CMsvEntry *entry; + int i, n; + + for (i = 0; i <= GN_MT_XX; i++) + folders[i] = KMsvNullIndexEntryId; + + folders[GN_MT_IN] = KMsvGlobalInBoxIndexEntryId; + folders[GN_MT_OU] = KMsvGlobalOutBoxIndexEntryId; + folders[GN_MT_AR] = KMsvSentEntryId; + next_folder = GN_MT_F1; + folder_count = 3; + + entry = g->msv_session->GetEntryL(MyFolders); + CleanupStack::PushL(entry); + entry->SetSortTypeL(TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue)); + n = entry->Count(); + + for (i = 0; i < n && next_folder < GN_MT_XX; i++) { + const TMsvEntry &child = (*entry)[i]; + + if (child.Id() == Templates) { + folders[GN_MT_TE] = Templates; + folder_count++; + } else if (child.Id() >= KFirstFreeEntryId) { + folders[next_folder++] = child.Id(); + folder_count++; + } + } + + CleanupStack::PopAndDestroy(entry); +} + + +void SMSObserver::RefreshL(void) +{ + if (next_folder == 0) FetchL(); +} + + +TUint16 SMSObserver::GetMT(TMsvId id) +{ + if (next_folder >= GN_MT_XX) return GN_MT_XX; + + folders[next_folder] = id; + return next_folder++; +} + + +static void GetStatusL(PktBuf &in, PktBuf &out) +{ + TUint32 number, unread; + int i, j, n; + CMsvEntry *entry; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in.FinishL(); + + number = 0; + unread = 0; + for (i = 0; i < GN_MT_XX; i++) { + if (sms_observer.folders[i] == KMsvNullIndexEntryId) continue; + + entry = g->msv_session->GetEntryL(sms_observer.folders[i]); + CleanupStack::PushL(entry); + entry->SetSortTypeL(TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue)); + n = entry->Count(); + + for (j = 0; j < n; j++) { + const TMsvEntry &f = (*entry)[j]; + if (f.Unread()) { + unread++; + } else { + number++; + } + } + + CleanupStack::PopAndDestroy(entry); + } + + out << (TUint16)GNAPPLET_MSG_SMS_STATUS_RESP; + out << (TUint16)GN_ERR_NONE; + out << number; + out << unread; + out << (TBool)false; + out << (TUint16)sms_observer.folder_count; +} + + +static void FolderListL(PktBuf &in, PktBuf &out) +{ + CMsvEntry *entry; + TUint32 i; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in.FinishL(); + + out << (TUint16)GNAPPLET_MSG_SMS_FOLDER_LIST_RESP; + out << (TUint16)GN_ERR_NONE; + out << (TUint16)sms_observer.folder_count; + + for (i = 0; i < GN_MT_XX; i++) { + if (sms_observer.folders[i] == KMsvNullIndexEntryId) continue; + + entry = g->msv_session->GetEntryL(sms_observer.folders[i]); + CleanupStack::PushL(entry); + + const TMsvEntry &f = entry->Entry(); + out << (TUint16)i << f.iDetails; + + CleanupStack::PopAndDestroy(entry); + } +} + + +static void FolderStatusL(PktBuf &in, PktBuf &out) +{ + CMsvEntry *entry; + TUint32 i, n; + TUint16 memtype; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> memtype; + in.FinishL(); + + if (memtype >= GN_MT_XX || sms_observer.folders[memtype] == KMsvNullIndexEntryId) { + out << (TUint16)GNAPPLET_MSG_SMS_FOLDER_STATUS_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + return; + } + + entry = g->msv_session->GetEntryL(sms_observer.folders[memtype]); + CleanupStack::PushL(entry); + entry->SetSortTypeL(TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue)); + n = entry->Count(); + + out << (TUint16)GNAPPLET_MSG_SMS_FOLDER_STATUS_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; + /// @todo erm, this is a waste of resources :o) better replace this when I have time + + // count sms entries + TUint32 count=0; + for( i=0; i<n; i++ ) { + const TMsvEntry &child = (*entry)[i]; + if( child.iMtm == KUidMsgTypeSMS ) + count++; + } + + out << count; + + for (i = 0; i < n; i++) { + // only sms are supported atm + const TMsvEntry &child = (*entry)[i]; + if( child.iMtm == KUidMsgTypeSMS ) + out << (TUint32)child.Id(); + } + + CleanupStack::PopAndDestroy(entry); +} + + +static void CreateFolderL(PktBuf &in, PktBuf &out) +{ + CMsvEntry *entry; + TMsvEntry f; + TBuf<64> name; + TUint16 memtype; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> name; + in.FinishL(); + + entry = g->msv_session->GetEntryL(MyFolders); + CleanupStack::PushL(entry); + + f.iType = KUidMsvFolderEntry; + f.iMtm = entry->Entry().iMtm; + f.iDetails.Set(name); + f.iServiceId = KMsvLocalServiceIndexEntryId; + + entry->CreateL(f); + memtype = sms_observer.GetMT(f.Id()); + + CleanupStack::PopAndDestroy(entry); + + out << (TUint16)GNAPPLET_MSG_SMS_FOLDER_CREATE_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype << name; +} + + +static void DeleteFolderL(PktBuf &in, PktBuf &out) +{ + CMsvEntry *entry; + TUint16 memtype; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> memtype; + in.FinishL(); + + if (memtype >= GN_MT_XX || sms_observer.folders[memtype] == KMsvNullIndexEntryId) { + out << (TUint16)GNAPPLET_MSG_SMS_FOLDER_DELETE_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + return; + } + + entry = g->msv_session->GetEntryL(MyFolders); + CleanupStack::PushL(entry); + + entry->DeleteL(sms_observer.folders[memtype]); + sms_observer.folders[memtype] = KMsvNullIndexEntryId; + + CleanupStack::PopAndDestroy(entry); + + out << (TUint16)GNAPPLET_MSG_SMS_FOLDER_DELETE_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; +} + + +static void ReadMessageL(PktBuf &in, PktBuf &out) +{ + TUint16 memtype; + TUint32 location; + CMsvEntry *entry; + CArrayFixFlat<TSms> *sms_array; + TUint8 status; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> memtype; + in >> location; + in.FinishL(); + + if (memtype >= GN_MT_XX || sms_observer.folders[memtype] == KMsvNullIndexEntryId) { + out << (TUint16)GNAPPLET_MSG_SMS_MESSAGE_READ_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + return; + } + + entry = g->msv_session->GetEntryL(location); + CleanupStack::PushL(entry); + + g->smsmtm->SwitchCurrentEntryL(entry->EntryId()); + g->smsmtm->LoadMessageL(); + const TMsvEntry &f = entry->Entry(); + const CSmsHeader &header = g->smsmtm->SmsHeader(); + const CSmsMessage &msg = header.Message(); + + out << (TUint16)GNAPPLET_MSG_SMS_MESSAGE_READ_RESP; + out << (TUint16)GN_ERR_NONE; + + sms_array = new (ELeave)CArrayFixFlat<TSms>(5); + CleanupStack::PushL(sms_array); + msg.EncodeMessagePDUsL(*sms_array); + out << (TUint16) sms_array->Count(); + for( int i=0; i<sms_array->Count(); i++ ) + out << (*sms_array)[i].PduL(); + CleanupStack::PopAndDestroy(sms_array); + + if (f.SendingState() == KMsvSendStateSent) { + status = GN_SMS_Sent; + } else if (f.SendingState() != KMsvSendStateNotApplicable && f.SendingState() != KMsvSendStateUnknown) { + status = GN_SMS_Unsent; + } else if (f.Unread()) { + status = GN_SMS_Unread; + } else { + status = GN_SMS_Read; + } + + out << status; + + CleanupStack::PopAndDestroy(entry); +} + + +static void WriteMessageL(PktBuf &in, PktBuf &out) +{ + TUint16 memtype; + TUint32 location; + CMsvEntry *entry; + TSms::TPdu pdu; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> memtype; + in >> location; + in >> pdu; + in.FinishL(); + + if (memtype >= GN_MT_XX || sms_observer.folders[memtype] == KMsvNullIndexEntryId) { + out << (TUint16)GNAPPLET_MSG_SMS_MESSAGE_WRITE_RESP; + out << (TUint16)GN_ERR_INVALIDMEMORYTYPE; + return; + } + + if (1) { + CMsvOperationWait *wait; + CMsvOperation *operation; + TMsvEntry f; + TInt error; + + f.iMtm = KUidMsgTypeSMS; + f.iType = KUidMsvMessageEntry; + f.iServiceId = KMsvLocalServiceIndexEntryId; + f.iDate.HomeTime(); + f.SetInPreparation(true); + + entry = CMsvEntry::NewL(*g->msv_session, sms_observer.folders[memtype], TMsvSelectionOrdering()); + CleanupStack::PushL(entry); + + wait = CMsvOperationWait::NewLC(); + wait->Start(); + operation = entry->CreateL(f, wait->iStatus); + CleanupStack::PushL(operation); + + while (CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle)) ; + TMsvLocalOperationProgress progress = McliUtils::GetLocalProgressL(*operation); + User::LeaveIfError(progress.iError); + + entry->SetEntryL(progress.iId); + location = progress.iId; + + CleanupStack::PopAndDestroy(2); + } else { + //!!!FIXME: modify existing entry + entry = g->msv_session->GetEntryL(location); + CleanupStack::PushL(entry); + } + + g->smsmtm->SwitchCurrentEntryL(entry->EntryId()); + g->smsmtm->RestoreServiceAndSettingsL(); + + TMsvEntry f; + f = entry->Entry(); + //f.iDate = msg_time; + //f.iDetails.Set(remote_number); + f.SetInPreparation(false); + + CSmsHeader &header = g->smsmtm->SmsHeader(); + CSmsMessage &msg = header.Message(); + + CArrayFixFlat<TSms> *sms_array; + TSms sms(pdu); + sms.SetUseDefaultSca(false); + sms_array = new (ELeave)CArrayFixFlat<TSms>(1); + CleanupStack::PushL(sms_array); + sms_array->AppendL(sms); + +#if 1 + msg.DecodeMessagePDUsL(*sms_array, true); +#endif +#if 0 + CSmsMessage *m = CSmsMessage::NewL(sms, CSmsBuffer::NewL(), true); + TSmsUtilities smsut; + g->smsmtm->SaveMessageL(); + TSmsUtilities::PopulateMsgEntry(f, *m, f.iServiceId); +#endif + + CleanupStack::PopAndDestroy(sms_array); + + entry->ChangeL(f); + + g->smsmtm->SaveMessageL(); + + out << (TUint16)GNAPPLET_MSG_SMS_MESSAGE_WRITE_RESP; + out << (TUint16)GN_ERR_NONE; + out << memtype; + out << location; + + CleanupStack::PopAndDestroy(entry); +} + + +static void SendMessageL(PktBuf &in, PktBuf &out) +{ + TSms::TPdu pdu; + RAdvGsmSmsMessaging messaging; + RAdvGsmSmsMessaging::TSmsSendResult result; + TRequestStatus status; + + g->InitPhoneInfoL(); + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> pdu; + in.FinishL(); + + TSms sms(pdu); + sms.SetUseDefaultSca(false); + + messaging.Open(*g->phone); + CleanupClosePushL(messaging); + messaging.SendAdvSmsMessage(status, sms, result); + User::WaitForRequest(status); + + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_SEND_RESP); + out << TUint16(status == KErrNone ? GN_ERR_NONE : GN_ERR_FAILED); + + CleanupStack::PopAndDestroy(1); +} + + +static void DeleteMessageL(PktBuf &in, PktBuf &out) +{ + TUint16 memtype; + TUint32 location; + CMsvEntry *entry; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> memtype; + in >> location; + in.FinishL(); + + if (memtype >= GN_MT_XX || sms_observer.folders[memtype] == KMsvNullIndexEntryId) { + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_DELETE_RESP); + out << TUint16(GN_ERR_INVALIDMEMORYTYPE); + return; + } + + entry = g->msv_session->GetEntryL(sms_observer.folders[memtype]); + CleanupStack::PushL(entry); + + TRAPD(error, entry->DeleteL(location)); + if (error != KErrNone) { + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_DELETE_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + } else { + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_DELETE_RESP); + out << TUint16(GN_ERR_NONE); + } + + CleanupStack::PopAndDestroy(entry); +} + + +static void MoveMessageL(PktBuf &in, PktBuf &out) +{ + TUint16 memtype, newfolder; + TUint32 location; + CMsvEntry *entry; + TRequestStatus status; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> memtype; + in >> location; + in >> newfolder; + in.FinishL(); + + if (memtype >= GN_MT_XX || sms_observer.folders[memtype] == KMsvNullIndexEntryId) { + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_MOVE_RESP); + out << TUint16(GN_ERR_INVALIDMEMORYTYPE); + return; + } + if (newfolder >= GN_MT_XX || sms_observer.folders[newfolder] == KMsvNullIndexEntryId) { + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_MOVE_RESP); + out << TUint16(GN_ERR_INVALIDMEMORYTYPE); + return; + } + + entry = g->msv_session->GetEntryL(sms_observer.folders[memtype]); + CleanupStack::PushL(entry); + + TRAPD(error, entry->MoveL(location, newfolder, status)); + if (error == KErrNone) { + WaitIfReqL(true, status); + error = status.Int(); + } + + if (error != KErrNone) { + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_MOVE_RESP); + out << TUint16(GN_ERR_INVALIDLOCATION); + } else { + out << TUint16(GNAPPLET_MSG_SMS_MESSAGE_MOVE_RESP); + out << TUint16(GN_ERR_NONE); + } + + CleanupStack::PopAndDestroy(entry); +} + + +static void ReadSmscL(PktBuf &in, PktBuf &out) +{ + TUint16 index; + TRequestStatus status; + CSmsSimParamOperation *op; + const CAdvGsmSmspList *sc; + RAdvGsmSmsMessaging::TSmspEntry e; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> index; + in.FinishL(); + + op = g->smsmtm->ReadSimParamsL(status); + CleanupStack::PushL(op); + WaitIfReqL(true, status); + if (status != KErrNone) { + out << (TUint16)GNAPPLET_MSG_SMS_CENTER_READ_RESP; + out << (TUint16)GN_ERR_FAILED; + return; + } + sc = &op->SmspList(); + if (sc->GetEntry(index, e) != KErrNone) { + CleanupStack::PopAndDestroy(1); + out << (TUint16)GNAPPLET_MSG_SMS_CENTER_READ_RESP; + out << (TUint16)GN_ERR_INVALIDLOCATION; + return; + } + Debug(_L("OK: %02x %S/%S"), e.iValidParams, &e.iText, &e.iServiceCentre.iTelNumber); + + out << (TUint16)GNAPPLET_MSG_SMS_CENTER_READ_RESP; + out << (TUint16)GN_ERR_NONE; + out << index; + out << e.iText; + out << TInt16(-1); + out << TUint8(GN_SMS_MF_Text); //!!!FIXME + + if (e.iValidParams & RAdvGsmSmsMessaging::KValidityPeriodIncluded) { + out << e.iValidityPeriod; + } else { + out << TUint8(0xff); + } + + if (e.iValidParams & RAdvGsmSmsMessaging::KServiceCentreAddressIncluded) { + out << TUint8(e.iServiceCentre.iTypeOfNumber) << e.iServiceCentre.iTelNumber; + } else { + out << TUint8(0) << _L(""); + } + + if (e.iValidParams & RAdvGsmSmsMessaging::KDestinationIncluded) { + out << TUint8(e.iDestination.iTypeOfNumber) << e.iDestination.iTelNumber; + } else { + out << TUint8(0) << _L(""); + } + + CleanupStack::PopAndDestroy(1); +} + + +static void WriteSmscL(PktBuf &in, PktBuf &out) +{ + TUint16 index; + TRequestStatus status; + CSmsSimParamOperation *op; + const CAdvGsmSmspList *sc; + RAdvGsmSmsMessaging::TSmspEntry e; + TInt16 defname; + TUint8 type; + TBuf<KGsmMaxTelNumberSize> number; + + g->InitSmsL(sms_observer); + sms_observer.RefreshL(); + + in >> index; + in >> e.iText; + in >> defname; + + in >> e.iProtocolId; + e.iValidParams |= RAdvGsmSmsMessaging::KProtocolIdIncluded; + + //e.iValidParams |= RAdvGsmSmsMessaging::KDcsIncluded; + e.iDcs = 0xf4; + + in >> e.iValidityPeriod; + e.iValidParams |= RAdvGsmSmsMessaging::KValidityPeriodIncluded; + + in >> type >> number; + if (type != 0 && number.Length() > 0) { + e.iServiceCentre.iTypeOfNumber = type; + e.iServiceCentre.iTelNumber = number; + e.iValidParams |= RAdvGsmSmsMessaging::KServiceCentreAddressIncluded; + } + + in >> type >> number; + if (type != 0 && number.Length() > 0) { + e.iDestination.iTypeOfNumber = type; + e.iDestination.iTelNumber = number; + e.iValidParams |= RAdvGsmSmsMessaging::KDestinationIncluded; + } + + in.FinishL(); + + op = g->smsmtm->ReadSimParamsL(status); + CleanupStack::PushL(op); + WaitIfReqL(true, status); + if (status != KErrNone) { + out << (TUint16)GNAPPLET_MSG_SMS_CENTER_WRITE_RESP; + out << (TUint16)GN_ERR_FAILED; + return; + } + //sc = &op->SmspList(); + sc = op->ServiceCentersLC(); + int err; + /* + if ((err = sc->ChangeEntry(index, e)) != KErrNone) { + if (0) { + */ + if ((err = sc->AddEntryL(e)) != KErrNone) { + Debug(_L("err: %d"), err); + CleanupStack::PopAndDestroy(1); + out << (TUint16)GNAPPLET_MSG_SMS_CENTER_WRITE_RESP; + out << (TUint16)GN_ERR_INVALIDLOCATION; + return; + } + //g->smsmtm->ServiceSettings().SetCommDbAction(CSmsSettings::EStoreToCommDb); + //g->smsmtm->ServiceSettings().AddSCAddressL(_L("alma"), _L("1234")); + + g->InitPhoneInfoL(); + RAdvGsmSmsMessaging messaging; + messaging.Open(*g->phone); + CleanupClosePushL(messaging); + + //messaging.NotifySmsParameterListChanged(status); + Debug(_L("OK: %02x %S/%S"), e.iValidParams, &e.iText, &e.iServiceCentre.iTelNumber); + //sc = messaging.RetrieveSmsParameterListLC(); + Debug(_L("elek: %d"), g->smsmtm->ServiceSettings().NumSCAddresses()); + User::LeaveIfError(messaging.StoreSmsParameterListL(sc)); + Debug(_L("Elek: %d"), g->smsmtm->ServiceSettings().NumSCAddresses()); + CleanupStack::PopAndDestroy(1); + + out << (TUint16)GNAPPLET_MSG_SMS_CENTER_WRITE_RESP; + out << (TUint16)GN_ERR_NONE; + out << index; + + CleanupStack::PopAndDestroy(2); +} + + +void HandleSMSMsg(PktBuf &in, PktBuf &out) +{ + TUint16 code; + + in >> code; + switch (code) { + case GNAPPLET_MSG_SMS_FOLDER_LIST_REQ: + FolderListL(in, out); + break; + + case GNAPPLET_MSG_SMS_FOLDER_STATUS_REQ: + FolderStatusL(in, out); + break; + + case GNAPPLET_MSG_SMS_FOLDER_CREATE_REQ: + CreateFolderL(in, out); + break; + + case GNAPPLET_MSG_SMS_FOLDER_DELETE_REQ: + DeleteFolderL(in, out); + break; + + case GNAPPLET_MSG_SMS_STATUS_REQ: + GetStatusL(in, out); + break; + + case GNAPPLET_MSG_SMS_MESSAGE_READ_REQ: + ReadMessageL(in, out); + break; + + case GNAPPLET_MSG_SMS_MESSAGE_WRITE_REQ: + WriteMessageL(in, out); + break; + + case GNAPPLET_MSG_SMS_MESSAGE_SEND_REQ: + SendMessageL(in, out); + break; + + case GNAPPLET_MSG_SMS_MESSAGE_DELETE_REQ: + DeleteMessageL(in, out); + break; + + case GNAPPLET_MSG_SMS_MESSAGE_MOVE_REQ: + MoveMessageL(in, out); + break; + + case GNAPPLET_MSG_SMS_CENTER_READ_REQ: + ReadSmscL(in, out); + break; + + case GNAPPLET_MSG_SMS_CENTER_WRITE_REQ: + WriteSmscL(in, out); + break; + + default: + out << (TUint16)((code + 1) & ~1); + out << (TUint16)GN_ERR_NOTSUPPORTED; + break; + } +} diff --git a/contrib/symbian/gnapplet/rfcomm.cpp b/contrib/symbian/gnapplet/rfcomm.cpp new file mode 100644 index 0000000..15818a3 --- /dev/null +++ b/contrib/symbian/gnapplet/rfcomm.cpp @@ -0,0 +1,99 @@ +/* + * $Id: rfcomm.cpp,v 1.2 2005/04/12 20:18:24 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides RfCOMM support. + * + */ + +#include <btmanclient.h> + +#include "rfcomm.h" + + +RfCOMM::~RfCOMM(void) +{ + CloseL(); + listen.Close(); + rserv.Close(); +} + + +void RfCOMM::ConstructL(int port) +{ + TInt error; + TBTSockAddr addr; + RBTMan btSecManager; + RBTSecuritySettings btSecSettings; + TBTServiceSecurity btServiceSecurity(TUid::Uid(0x107d4df2), KSolBtRFCOMM, 0); + TRequestStatus rs; + + rserv.Connect(); + + if ((error = listen.Open(rserv, _L("RFCOMM"))) != KErrNone) { + User::Leave(error); + } + + addr.SetPort(port); + if ((error = listen.Bind(addr)) != KErrNone) { + User::Leave(error); + } + + listen.Listen(1); + + btSecManager.Connect(); + btSecSettings.Open(btSecManager); + btServiceSecurity.SetAuthentication(TRUE); + btServiceSecurity.SetEncryption(TRUE); + btServiceSecurity.SetAuthorisation(TRUE); + btServiceSecurity.SetChannelID(port); + btSecSettings.RegisterService(btServiceSecurity, rs); + User::WaitForRequest(rs); +} + + +void RfCOMM::AcceptL(TRequestStatus &rs) +{ + User::LeaveIfError(conn.Open(rserv)); + + listen.Accept(conn, rs); +} + + +void RfCOMM::CloseL(void) +{ + conn.Close(); +} + + +void RfCOMM::ReadL(TRequestStatus &rs, TDes8 &buf) +{ + conn.Read(buf, rs); +} + + +void RfCOMM::WriteL(TRequestStatus &rs, const TDes8 &buf) +{ + conn.Write(buf, rs); +} diff --git a/contrib/symbian/gnapplet/rfcomm.h b/contrib/symbian/gnapplet/rfcomm.h new file mode 100644 index 0000000..3168997 --- /dev/null +++ b/contrib/symbian/gnapplet/rfcomm.h @@ -0,0 +1,52 @@ +/* + * $Id: rfcomm.h,v 1.1.1.1 2004/04/03 21:29:46 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2004 BORBELY Zoltan + * + * This file provides RfCOMM support. + * + */ + +#ifndef __GNAPPLET_RFCOMM_H +#define __GNAPPLET_RFCOMM_H + +#include <bt_sock.h> + +#include "device.h" + + +class RfCOMM: public Device { + RSocketServ rserv; + RSocket listen; + RSocket conn; +public: + RfCOMM(void) {}; + ~RfCOMM(void); + void ConstructL(int port); + void AcceptL(TRequestStatus &rs); + void CloseL(void); + void ReadL(TRequestStatus &rs, TDes8 &buf); + void WriteL(TRequestStatus &rs, const TDes8 &buf); +}; + +#endif diff --git a/contrib/symbian/gnapplet/tcpip.cpp b/contrib/symbian/gnapplet/tcpip.cpp new file mode 100644 index 0000000..38b16e9 --- /dev/null +++ b/contrib/symbian/gnapplet/tcpip.cpp @@ -0,0 +1,84 @@ +/* + * $Id: tcpip.cpp,v 1.1 2005/09/01 22:28:50 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2005 BORBELY Zoltan + * + * This file provides TCP/IP support. + * + */ + +#include "tcpip.h" + + +TCPIP::~TCPIP(void) +{ + CloseL(); + listen.Close(); + rserv.Close(); +} + + +void TCPIP::ConstructL(TUint16 port) +{ + TInt error; + TInetAddr addr; + + User::LeaveIfError(rserv.Connect()); + + if ((error = listen.Open(rserv, KAfInet, KSockStream, KProtocolInetTcp)) != KErrNone) { + User::Leave(error); + } + + addr.SetPort(port); + if ((error = listen.Bind(addr)) != KErrNone) { + User::Leave(error); + } + + listen.Listen(1); +} + + +void TCPIP::AcceptL(TRequestStatus &rs) +{ + User::LeaveIfError(conn.Open(rserv)); + + listen.Accept(conn, rs); +} + + +void TCPIP::CloseL(void) +{ + conn.Close(); +} + + +void TCPIP::ReadL(TRequestStatus &rs, TDes8 &buf) +{ + conn.Read(buf, rs); +} + + +void TCPIP::WriteL(TRequestStatus &rs, const TDes8 &buf) +{ + conn.Write(buf, rs); +} diff --git a/contrib/symbian/gnapplet/tcpip.h b/contrib/symbian/gnapplet/tcpip.h new file mode 100644 index 0000000..973a6b8 --- /dev/null +++ b/contrib/symbian/gnapplet/tcpip.h @@ -0,0 +1,52 @@ +/* + * $Id: tcpip.h,v 1.1 2005/09/01 22:28:50 bozo Exp $ + * + * G N A P P L E T + * + * gnapplet is a gnbus protocol driver for symbian phones. + * + * This file is part of gnokii. + * + * Gnokii is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Gnokii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gnokii; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2005 BORBELY Zoltan + * + * This file provides TCP/IP support. + * + */ + +#ifndef __GNAPPLET_TCPIP_H +#define __GNAPPLET_TCPIP_H + +#include <in_sock.h> + +#include "device.h" + + +class TCPIP: public Device { + RSocketServ rserv; + RSocket listen; + RSocket conn; +public: + TCPIP(void) {}; + ~TCPIP(void); + void ConstructL(TUint16 port); + void AcceptL(TRequestStatus &rs); + void CloseL(void); + void ReadL(TRequestStatus &rs, TDes8 &buf); + void WriteL(TRequestStatus &rs, const TDes8 &buf); +}; + +#endif diff --git a/contrib/symbian/readme.txt b/contrib/symbian/readme.txt new file mode 100644 index 0000000..3d508db --- /dev/null +++ b/contrib/symbian/readme.txt @@ -0,0 +1,4 @@ +Gnapplet from Gnokii (www.gnokii.org) +licensed with GNU GPL2 +version 0.18 +should work with many Series 60 1st, 2nd edition and other (Symbian 6.x - 8.x) |