Open Source Telephony
 help / color / mirror / Atom feed
From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 5/7] hardwaremanipulator: Add multi-page support for CBS message
Date: Mon, 25 Jun 2012 16:38:01 +0200	[thread overview]
Message-ID: <1340635083-5877-6-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1340635083-5877-1-git-send-email-philippe.nunes@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2142 bytes --]

---
 src/hardwaremanipulator.cpp |   35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp
index c19b507..b746229 100644
--- a/src/hardwaremanipulator.cpp
+++ b/src/hardwaremanipulator.cpp
@@ -123,13 +123,44 @@ void HardwareManipulator::constructCBMessage(const QString &messageCode, int geo
     m.setPage(pag);
     m.setText(content);
 
+    uint nbPages, spaceLeftInLast;
+
+    if ( scheme == 0 && 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 ));
+    }
+
+    m.computeSize( nbPages, spaceLeftInLast );
+    if ( npag < nbPages ) {
+	    warning(tr("Invalid number of pages"),
+		tr("The required number of pages is "
+	                   "higher than the given number"));
+	    m.setNumPages(nbPages);
+    }
+
     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));
+    if( m.shouldSplit() ) {
+        QList<QCBSMessage> list = m.split();
+
+        for( int i =0; i < list.count(); i++ ) {
+            QByteArray pdu = list[i].toPdu();
+             emit unsolicitedCommand(QString("+CBM: ")+QString::number(pdu.length())+'\r'+'\n'+ PS_toHex(pdu));
+         }
+    } else {
+        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 )
-- 
1.7.9.5


  parent reply	other threads:[~2012-06-25 14:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 14:37 [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD Philippe Nunes
2012-06-25 14:37 ` [PATCH 1/7] control: Fix empty sender checking Philippe Nunes
2012-06-22  8:20   ` Denis Kenzior
2012-06-25 14:37 ` [PATCH 2/7] controbase: Add combobox for CBS scheme selection Philippe Nunes
2012-06-22  8:08   ` Denis Kenzior
2012-06-25 14:37 ` [PATCH 3/7] qcbsmessage: Extend QCBSMessage class Philippe Nunes
2012-06-22 14:36   ` Denis Kenzior
2012-06-25 14:38 ` [PATCH 4/7] hardwaremanipulator: Add UCS2 encoding support for CBS message Philippe Nunes
2012-06-25 14:38 ` Philippe Nunes [this message]
2012-06-22  8:12   ` [PATCH 5/7] hardwaremanipulator: Add multi-page " Denis Kenzior
2012-06-25 14:38 ` [PATCH 6/7] sms: Extend CBS message formating to use UCS2 scheme Philippe Nunes
2012-06-22 14:36   ` Denis Kenzior
2012-06-25 14:38 ` [PATCH 7/7] hardwaremanipulator: Add USC2 encoding support for USSD Philippe Nunes
2012-06-22 14:09   ` 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=1340635083-5877-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox