Open Source Telephony
 help / color / mirror / Atom feed
From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH v2 2/4] qcbsmessage: apply the same coding scheme for all the pages
Date: Fri, 29 Jun 2012 17:53:01 +0200	[thread overview]
Message-ID: <1340985183-22049-3-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1340985183-22049-1-git-send-email-philippe.nunes@linux.intel.com>

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

---
 src/qcbsmessage.cpp |   38 ++++++++++++++------------------------
 src/qcbsmessage.h   |    1 -
 2 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/src/qcbsmessage.cpp b/src/qcbsmessage.cpp
index e4403ae..da975dd 100644
--- a/src/qcbsmessage.cpp
+++ b/src/qcbsmessage.cpp
@@ -408,6 +408,9 @@ int QCBSMessage::bestScheme() const
     uint len = body.length();
     bool gsmSafe;
 
+    if ( d->mDataCodingScheme != (QSMSDataCodingScheme)-1 )
+        return d->mDataCodingScheme;
+
     // Encode zero-length bodies in the default alphabet.
     if ( len == 0 )
         return QSMS_DefaultAlphabet;
@@ -430,14 +433,8 @@ int QCBSMessage::bestScheme() const
 QByteArray QCBSMessage::toPdu() const
 {
     QCBSDeliverMessage deliver;
-    QSMSDataCodingScheme scheme;
-
-    if(dataCodingScheme() == -1)
-        scheme = (QSMSDataCodingScheme)bestScheme();
-    else
-        scheme = (QSMSDataCodingScheme)dataCodingScheme();
 
-    deliver.pack( *this, scheme );
+    deliver.pack( *this, (QSMSDataCodingScheme)bestScheme() );
     return deliver.toByteArray();
 }
 
@@ -461,7 +458,7 @@ void QCBSMessage::computeSize( uint& numPages, uint& spaceLeftInLast ) const
 {
     QString body = text();
     uint len = body.length();
-    uint scheme= dataCodingScheme();
+    uint scheme= bestScheme();
 
     if ( scheme == QSMS_DefaultAlphabet ) {
         // Encode the message using 7-bit GSM.
@@ -493,19 +490,6 @@ void QCBSMessage::computeSize( uint& numPages, uint& spaceLeftInLast ) const
 }
 
 /*!
-    Returns true if this message needs to be split into multiple messages
-    before being transmitted over a GSM network; otherwise returns false.
-
-    \sa split()
-*/
-bool QCBSMessage::shouldSplit() const
-{
-    uint numPages, spaceLeftInLast;
-    this->computeSize( numPages, spaceLeftInLast );
-    return ( numPages <=1 ? false : true );
-}
-
-/*!
     Split this message into several pages of 88 bytes for
     transmission over a GSM network.
 
@@ -521,11 +505,13 @@ QList<QCBSMessage> QCBSMessage::split() const
         // Splitting is not necessary, so return a list with one page.
         list += *this;
         return list;
-    }
+    } else if ( numPages > 15)
+        //Up to 15 pages can be concatenated to form a CBS message
+        numPages = 15;
 
     // Get the number of characters to transmit in each page.
     int split;
-    uint scheme= dataCodingScheme();
+    uint scheme= bestScheme();
 
     switch ( scheme ) {
         case QSMS_UCS2Alphabet:
@@ -542,7 +528,7 @@ QList<QCBSMessage> QCBSMessage::split() const
     QCBSMessage tmp;
     number = 1;
     QString txt = text();
-    while ( posn < txt.length() ) {
+    while ( posn < txt.length() && number <= numPages ) {
         tmp = *this;
         len = txt.length() - posn;
         if ( len > split ) {
@@ -550,6 +536,10 @@ QList<QCBSMessage> QCBSMessage::split() const
         }
         tmp.setText( txt.mid( posn, len ) );
         tmp.setPage( number++ );
+        tmp.setNumPages(numPages);
+        // Set mDataCodingScheme to apply the same scheme for all the pages
+        // of the CBS message
+        tmp.setDataCodingScheme(scheme);
         posn += len;
         list.append(tmp);
     }
diff --git a/src/qcbsmessage.h b/src/qcbsmessage.h
index 0f055b7..bfb879a 100644
--- a/src/qcbsmessage.h
+++ b/src/qcbsmessage.h
@@ -97,7 +97,6 @@ public:
     static QCBSMessage fromPdu( const QByteArray& pdu );
 
     int bestScheme() const;
-    bool shouldSplit() const;
     QList<QCBSMessage> split() const;
     void computeSize( uint& numPages, uint& spaceLeftInLast ) const;
 
-- 
1.7.9.5


  parent reply	other threads:[~2012-06-29 15:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29 15:52 [PATCH v2 0/4] phonesim: CBS/USSD improvments Philippe Nunes
2012-06-29 15:53 ` [PATCH v2 1/4] controbase: Remove entries in CBM UI Philippe Nunes
2012-06-29 15:53 ` Philippe Nunes [this message]
2012-06-29 15:53 ` [PATCH v2 3/4] hardwaremanipulator: Use the best scheme for CBS message Philippe Nunes
2012-06-29 15:53 ` [PATCH v2 4/4] hardwaremanipulator: Add multi-page support " Philippe Nunes
2012-07-09 16:04 ` [PATCH v2 0/4] phonesim: CBS/USSD improvments 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=1340985183-22049-3-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