From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 3/6] hardwaremanipulator: Use the best scheme for CBS message
Date: Wed, 27 Jun 2012 17:10:42 +0200 [thread overview]
Message-ID: <1340809845-26595-4-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1340809845-26595-1-git-send-email-philippe.nunes@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 6982 bytes --]
---
src/control.cpp | 9 +++----
src/hardwaremanipulator.cpp | 61 ++++++++++++++++++++++---------------------
src/hardwaremanipulator.h | 6 +++--
3 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/src/control.cpp b/src/control.cpp
index 27910c2..9085acd 100644
--- a/src/control.cpp
+++ b/src/control.cpp
@@ -329,12 +329,9 @@ void ControlWidget::sendREG()
void ControlWidget::sendCBM()
{
- QString pdu = p->constructCBMessage(ui->leMessageCode->text(),ui->cbGeographicalScope->currentIndex(),
- ui->leUpdateNumber->text(),ui->leChannel->text(),ui->leScheme->text(),
- ui->cbLanguage->currentIndex(),ui->leNumPages->text(),ui->lePage->text(),
- ui->teContent->toPlainText());
-
- emit unsolicitedCommand(QString("+CBM: ")+QString::number(pdu.length()/2)+'\r'+'\n'+ pdu);
+ p->constructCBMessage(ui->leMessageCode->text(),ui->cbGeographicalScope->currentIndex(),
+ ui->leUpdateNumber->text(),ui->leChannel->text(),
+ ui->cbLanguage->currentIndex(),ui->teContent->toPlainText());
}
void ControlWidget::sendSMSMessage()
diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp
index 2d7b141..3d0f54a 100644
--- a/src/hardwaremanipulator.cpp
+++ b/src/hardwaremanipulator.cpp
@@ -62,8 +62,8 @@ void HardwareManipulator::setPhoneNumber( const QString& )
QString PS_toHex( const QByteArray& binary );
-QString HardwareManipulator::constructCBMessage(const QString &messageCode, int geographicalScope, const QString &updateNumber,
- const QString &channel, const QString &/*scheme*/, int language, const QString &numPages, const QString &page, const QString &content)
+void HardwareManipulator::constructCBMessage(const QString &messageCode, int geographicalScope, const QString &updateNumber,
+ const QString &channel, int language, const QString &content)
{
bool ok;
@@ -71,10 +71,9 @@ QString HardwareManipulator::constructCBMessage(const QString &messageCode, int
if ( !ok ) {
warning(tr("Invalid Message Code"),
tr("Message code 3 hex digits long and no larger than 3FF"));
- return "";
+ return;
}
-
QCBSMessage::GeographicalScope gs = (QCBSMessage::GeographicalScope)geographicalScope;
uint un = convertString(updateNumber,NIBBLE_MAX,ONE_CHAR,HEX_BASE,&ok);
@@ -82,7 +81,7 @@ QString HardwareManipulator::constructCBMessage(const QString &messageCode, int
warning(tr("Invalid Update Number"),
tr("Update number must be 1 hex digit long"
"and no larger than F"));
- return "";
+ return;
}
@@ -91,43 +90,45 @@ QString HardwareManipulator::constructCBMessage(const QString &messageCode, int
warning(tr("Invalid Channel,"),
tr("Channel must be 4 hex digits long "
"and no larger than FFFF"));
- return "";
+ return;
}
- //scheme is currently hardcoded to QSMS8_BitCodingScheme
- //uint sch = convertString(scheme, NIBBLE_MAX, ONE_CHAR,HEX_BASE,&ok);
- //if ( !ok )
- // return "";
-
QCBSMessage::Language lang = (QCBSMessage::Language)language;
- uint npag = convertString(numPages, NIBBLE_MAX,ONE_CHAR,HEX_BASE,&ok);
- if ( !ok ) {
- warning(tr("Invalid number of pages,"),
- tr("Number of pages must be 1 hex digit long "
- "and no larger than F"));
- return "";
- }
-
- uint pag = convertString(page, NIBBLE_MAX,ONE_CHAR,HEX_BASE,&ok);
- if ( !ok ) {
- warning(tr("Invalid page number,"),
- tr("Page number must be 1 hex digit long "
- "and no larger than F"));
- return "";
- }
-
QCBSMessage m;
m.setMessageCode(mc);
m.setScope(gs);
m.setUpdateNumber(un);
m.setChannel(ch);
m.setLanguage(lang);
- m.setNumPages(npag);
- m.setPage(pag);
+ m.setPage(1);
m.setText(content);
+ m.setDataCodingScheme(m.bestScheme());
+
+ if ( m.dataCodingScheme() == QSMS_DefaultAlphabet &&
+ content.length() > (15*93)) {
+ warning(tr("Text too long"),
+ tr("The maximum number of pages (15) "
+ "is reached - text is truncated"));
+ m.setText(content.mid( 0, 15*93 ));
+ } else if (content.length() > (15*40)) {
+ warning(tr("Text too long"),
+ tr("The maximum number of pages (15) "
+ "is reached - text is truncated"));
+ m.setText(content.mid( 0, 15*40 ));
+ }
+
+ uint nbPages, spaceLeftInLast;
+ m.computeSize( nbPages, spaceLeftInLast );
+ m.setNumPages(nbPages);
- return PS_toHex( m.toPdu() );
+ sendCBS(m);
+}
+
+void HardwareManipulator::sendCBS( const QCBSMessage &m )
+{
+ QByteArray pdu = m.toPdu();
+ emit unsolicitedCommand(QString("+CBM: ")+QString::number(pdu.length())+'\r'+'\n'+ PS_toHex(pdu));
}
void HardwareManipulator::constructSMSMessage( const int type, const QString &sender, const QString &serviceCenter, const QString &text )
diff --git a/src/hardwaremanipulator.h b/src/hardwaremanipulator.h
index 881125e..87a8c6e 100644
--- a/src/hardwaremanipulator.h
+++ b/src/hardwaremanipulator.h
@@ -25,6 +25,7 @@
#include "qsmsmessagelist.h"
class QSMSMessage;
+class QCBSMessage;
class QVMMessage;
class SimRules;
struct CallInfo;
@@ -43,6 +44,7 @@ public slots:
virtual void handleToData( const QString& );
virtual void setPhoneNumber( const QString& );
virtual void constructSMSMessage(const int type, const QString &sender, const QString &serviceCenter, const QString &text);
+ virtual void sendCBS( const QCBSMessage& m );
virtual void sendSMS( const QSMSMessage& m );
virtual void sendVMNotify( int type, int count, const QList<QVMMessage> &received, const QList<QVMMessage> &deleted, const QString &mailbox );
virtual void sendUSSD( bool cancel, bool response, const QString &content );
@@ -63,8 +65,8 @@ signals:
void stateChangedToHangup( int callId );
protected:
- virtual QString constructCBMessage(const QString &messageCode, int geographicalScope, const QString &updateNumber, const QString &channel,
- const QString &scheme, int language, const QString &numPages, const QString &page, const QString &content);
+ virtual void constructCBMessage(const QString &messageCode, int geographicalScope, const QString &updateNumber, const QString &channel,
+ int language, const QString &content);
virtual void constructSMSDatagram(int src, int dst, const QString &sender, const QByteArray &data, const QByteArray &contentType);
virtual void warning(const QString &title, const QString &message);
--
1.7.9.5
next prev parent reply other threads:[~2012-06-27 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 15:10 [PATCH 0/6] phonesim: CBS/USSD improvments Philippe Nunes
2012-06-27 15:10 ` [PATCH 1/6] controbase: Remove entries in CBM UI Philippe Nunes
2012-06-27 15:10 ` [PATCH 2/6] qcbsmessage: Add bestScheme method in QCBSMessage class Philippe Nunes
2012-06-24 21:44 ` Denis Kenzior
2012-06-27 15:10 ` Philippe Nunes [this message]
2012-06-24 22:12 ` [PATCH 3/6] hardwaremanipulator: Use the best scheme for CBS message Denis Kenzior
2012-06-27 15:10 ` [PATCH 4/6] hardwaremanipulator: Add multi-page support " Philippe Nunes
2012-06-27 15:10 ` [PATCH 5/6] phonesim: Add support for USSD answer Philippe Nunes
2012-06-24 21:44 ` Denis Kenzior
2012-06-27 15:10 ` [PATCH 6/6] phonesim: Add support for USSD session cancellation Philippe Nunes
2012-06-24 21:44 ` Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340809845-26595-4-git-send-email-philippe.nunes@linux.intel.com \
--to=philippe.nunes@linux.intel.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.