All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/7] controbase: Add combobox for CBS scheme selection
  2012-06-25 14:37 ` [PATCH 2/7] controbase: Add combobox for CBS scheme selection Philippe Nunes
@ 2012-06-22  8:08   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2012-06-22  8:08 UTC (permalink / raw)
  To: ofono

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

Hi Philippe,

> +<item row="0" column="3">
> +<widget class="QComboBox" name="cbScheme">
> +<property name="currentIndex">
> +<number>0</number>
> +</property>
> +<item>
> +<property name="text">
> +<string>Default GSM</string>
> +</property>
> +</item>
> +<item>
> +<property name="text">
> +<string>UCS2</string>
> +</property>
> +</item>
> +</widget>
> +</item>

Since you're adding intelligence to figure out the 'best' encoding 
scheme anyway, are you sure these are actually needed?  The only reason 
to add this is if you have english characters but want to force encoding 
in UCS2.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/7] hardwaremanipulator: Add multi-page support for CBS message
  2012-06-25 14:38 ` [PATCH 5/7] hardwaremanipulator: Add multi-page " Philippe Nunes
@ 2012-06-22  8:12   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2012-06-22  8:12 UTC (permalink / raw)
  To: ofono

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

Hi Philippe,

On 06/25/2012 09:38 AM, Philippe Nunes wrote:
> ---
>   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);
> +    }
> +

Since you're doing this, feel free to simply take out the 'Page' and 
'Number of pages' entries in the UI.

The current UI provides way too much detail as it was used to test the 
oFono handling of repeated pages, outdated update numbers, out-of-order 
pages, etc.  However, these can be just as easily done as a unit test now.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/7] control: Fix empty sender checking
  2012-06-25 14:37 ` [PATCH 1/7] control: Fix empty sender checking Philippe Nunes
@ 2012-06-22  8:20   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2012-06-22  8:20 UTC (permalink / raw)
  To: ofono

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

Hi Philippe,

On 06/25/2012 09:37 AM, Philippe Nunes wrote:
> ---
>   src/control.cpp |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 7/7] hardwaremanipulator: Add USC2 encoding support for USSD.
  2012-06-25 14:38 ` [PATCH 7/7] hardwaremanipulator: Add USC2 encoding support for USSD Philippe Nunes
@ 2012-06-22 14:09   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2012-06-22 14:09 UTC (permalink / raw)
  To: ofono

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

Hi Philippe,

On 06/25/2012 09:38 AM, Philippe Nunes wrote:
> ---
>   src/hardwaremanipulator.cpp |   31 +++++++++++++++++++++++++++----
>   1 file changed, 27 insertions(+), 4 deletions(-)
>

Patch has been applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/7] qcbsmessage: Extend QCBSMessage class
  2012-06-25 14:37 ` [PATCH 3/7] qcbsmessage: Extend QCBSMessage class Philippe Nunes
@ 2012-06-22 14:36   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2012-06-22 14:36 UTC (permalink / raw)
  To: ofono

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

Hi Philippe,

On 06/25/2012 09:37 AM, Philippe Nunes wrote:
> ---
>   src/qcbsmessage.cpp |  140 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>   src/qcbsmessage.h   |    7 +++
>   2 files changed, 146 insertions(+), 1 deletion(-)
>

Patch has been applied.  I added a tiny follow on commit to fix up some 
formatting.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/7] sms: Extend CBS message formating to use UCS2 scheme
  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
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2012-06-22 14:36 UTC (permalink / raw)
  To: ofono

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

Hi Philippe,

On 06/25/2012 09:38 AM, Philippe Nunes wrote:
> ---
>   src/qsmsmessage.cpp |  119 +++++++++++++++++++++++++++++++++++++++++++++++----
>   1 file changed, 111 insertions(+), 8 deletions(-)
>

Patch has been applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD
@ 2012-06-25 14:37 Philippe Nunes
  2012-06-25 14:37 ` [PATCH 1/7] control: Fix empty sender checking Philippe Nunes
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:37 UTC (permalink / raw)
  To: ofono

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

phonesim is extended to support UCS2 encoding regarding CBS/USSD messages: 
- for CBS, a scheme combobox is now available for user selection.
- for USSD, the best scheme is used based on the content of the USSD text string.

phonesim is also able now to split the CBS text (according the chosen scheme) and send all the pages of the CBS message.  


Philippe Nunes (7):
  control: Fix empty sender checking
  controbase: Add combobox for CBS scheme selection
  qcbsmessage: Extend QCBSMessage class
  hardwaremanipulator: Add UCS2 encoding support for CBS message
  hardwaremanipulator: Add multi-page support for CBS message
  sms: Extend CBS message formating to use UCS2 scheme
  hardwaremanipulator: Add USC2 encoding support for USSD.

 src/control.cpp             |    8 +--
 src/controlbase.ui          |   36 ++++++-----
 src/hardwaremanipulator.cpp |   90 ++++++++++++++++++++++------
 src/hardwaremanipulator.h   |    6 +-
 src/qcbsmessage.cpp         |  140 ++++++++++++++++++++++++++++++++++++++++++-
 src/qcbsmessage.h           |    7 +++
 src/qsmsmessage.cpp         |  119 +++++++++++++++++++++++++++++++++---
 7 files changed, 357 insertions(+), 49 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/7] control: Fix empty sender checking
  2012-06-25 14:37 [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD Philippe Nunes
@ 2012-06-25 14:37 ` 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
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:37 UTC (permalink / raw)
  To: ofono

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

---
 src/control.cpp |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/control.cpp b/src/control.cpp
index ee1e7d8..27910c2 100644
--- a/src/control.cpp
+++ b/src/control.cpp
@@ -339,7 +339,7 @@ void ControlWidget::sendCBM()
 
 void ControlWidget::sendSMSMessage()
 {
-    if (ui->leSMSClass->text().isEmpty()) {
+    if (ui->leMessageSender->text().isEmpty()) {
         p->warning(tr("Invalid Sender"),
                 tr("Sender must not be empty"));
         return;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/7] controbase: Add combobox for CBS scheme selection
  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-25 14:37 ` Philippe Nunes
  2012-06-22  8:08   ` Denis Kenzior
  2012-06-25 14:37 ` [PATCH 3/7] qcbsmessage: Extend QCBSMessage class Philippe Nunes
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:37 UTC (permalink / raw)
  To: ofono

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

---
 src/controlbase.ui |   36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/controlbase.ui b/src/controlbase.ui
index ce675d2..b1a9ff1 100644
--- a/src/controlbase.ui
+++ b/src/controlbase.ui
@@ -531,7 +531,7 @@
              <string>&amp;Scheme</string>
             </property>
             <property name="buddy">
-             <cstring>leScheme</cstring>
+             <cstring>cbScheme</cstring>
             </property>
            </widget>
           </item>
@@ -555,19 +555,6 @@
             </property>
            </widget>
           </item>
-          <item row="0" column="3">
-           <widget class="QLineEdit" name="leScheme">
-            <property name="text">
-             <string>4</string>
-            </property>
-            <property name="maxLength">
-             <number>1</number>
-            </property>
-            <property name="readOnly">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
           <item row="0" column="1">
            <widget class="QLineEdit" name="leMessageCode">
             <property name="text">
@@ -635,6 +622,23 @@
             </property>
            </widget>
           </item>
+          <item row="0" column="3">
+           <widget class="QComboBox" name="cbScheme">
+            <property name="currentIndex">
+             <number>0</number>
+            </property>
+            <item>
+             <property name="text">
+              <string>Default GSM</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>UCS2</string>
+             </property>
+            </item>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>
@@ -1575,7 +1579,8 @@
   <tabstop>pbSendSMSDatagram</tabstop>
   <tabstop>atViewer</tabstop>
   <tabstop>openSpecButton</tabstop>
-  <tabstop>leScheme</tabstop>
+  <tabstop>teContent</tabstop>
+  <tabstop>cbScheme</tabstop>
   <tabstop>leNumPages</tabstop>
   <tabstop>lePage</tabstop>
   <tabstop>cbGeographicalScope</tabstop>
@@ -1591,7 +1596,6 @@
   <tabstop>leLAC</tabstop>
   <tabstop>pbSendCellBroadcast</tabstop>
   <tabstop>leCellID</tabstop>
-  <tabstop>teContent</tabstop>
   <tabstop>tabWidget</tabstop>
   <tabstop>leChannel</tabstop>
   <tabstop>cbLanguage</tabstop>
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/7] qcbsmessage: Extend QCBSMessage class
  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-25 14:37 ` [PATCH 2/7] controbase: Add combobox for CBS scheme selection Philippe Nunes
@ 2012-06-25 14:37 ` 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
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:37 UTC (permalink / raw)
  To: ofono

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

---
 src/qcbsmessage.cpp |  140 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/qcbsmessage.h   |    7 +++
 2 files changed, 146 insertions(+), 1 deletion(-)

diff --git a/src/qcbsmessage.cpp b/src/qcbsmessage.cpp
index fc17ae0..eb360bc 100644
--- a/src/qcbsmessage.cpp
+++ b/src/qcbsmessage.cpp
@@ -51,6 +51,7 @@ public:
     uint mUpdateNumber;
     uint mChannel;
     QCBSMessage::Language mLanguage;
+    uint mDataCodingScheme;
     uint mPage;
     uint mNumPages;
     QString mText;
@@ -268,6 +269,30 @@ void QCBSMessage::setLanguage( QCBSMessage::Language lang )
 }
 
 /*!
+    Returns the recommended data coding scheme for encoding CBS text strings.
+    The default value is -1, which indicates that the best scheme should be chosen
+    based on the contents of the CBS text string.
+
+    \sa setDataCodingScheme()
+*/
+int QCBSMessage::dataCodingScheme() const
+{
+    return d->mDataCodingScheme;
+}
+
+/*!
+    Sets the recommended data coding scheme for encoding CBS text strings to \a value.
+    The value -1 indicates that the best scheme should be chosen based on the contents
+    of the CBS text string.
+
+    \sa dataCodingScheme()
+*/
+void QCBSMessage::setDataCodingScheme( int value )
+{
+    d->mDataCodingScheme = value;
+}
+
+/*!
     Returns the page number for this cell broadcast message if the
     information that it contains is split over multiple pages.
 
@@ -398,7 +423,14 @@ static QSMSDataCodingScheme bestScheme( const QString& body )
 QByteArray QCBSMessage::toPdu() const
 {
     QCBSDeliverMessage deliver;
-    deliver.pack( *this, bestScheme( text() ) );
+    QSMSDataCodingScheme scheme;
+
+	if(dataCodingScheme() == -1)
+        scheme = bestScheme( text() );
+    else
+        scheme = (QSMSDataCodingScheme)dataCodingScheme();
+
+    deliver.pack( *this, scheme );
     return deliver.toByteArray();
 
 }
@@ -412,3 +444,109 @@ QCBSMessage QCBSMessage::fromPdu( const QByteArray& pdu )
     QCBSDeliverMessage deliver( pdu );
     return deliver.unpack();
 }
+
+/*!
+    Compute an estimate for the number of pages that will need
+    to be used to send this CBS message (\a numMessages), and the
+    number of spare characters that are left in the last message
+    before it overflows (\a spaceLeftInLast).
+*/
+void QCBSMessage::computeSize( uint& numPages, uint& spaceLeftInLast ) const
+{
+    QString body = text();
+    uint len = body.length();
+    uint scheme= dataCodingScheme();
+
+    if ( scheme == QSMS_DefaultAlphabet ) {
+        // Encode the message using 7-bit GSM.
+        if ( len <= 93 ) { // (82*8)/7 = 93 characters
+            numPages = 1;
+            spaceLeftInLast = 93 - len;
+        } else {
+            numPages = ( len + 92 ) / 93;
+            len %= 93;
+            if ( len != 0 )
+                spaceLeftInLast = 93 - len;
+            else
+                spaceLeftInLast = 0;
+        }
+    } else {
+        // Encode the message with unicode.
+        if ( len <= 40 ) { // 40 = 82/2 - 2 (2 GSM 7-bit ISO 639 characters).
+            numPages = 1;
+            spaceLeftInLast = 40 - len;
+        } else {
+            numPages = ( len + 39 ) / 40;
+            len %= 40;
+            if ( len != 0 )
+                spaceLeftInLast = 40 - len;
+            else
+                spaceLeftInLast = 0;
+        }
+    }
+}
+
+/*!
+    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.
+
+    \sa shouldSplit()
+*/
+QList<QCBSMessage> QCBSMessage::split() const
+{
+    QList<QCBSMessage> list;
+    uint numPages, spaceLeftInLast;
+
+    computeSize( numPages, spaceLeftInLast );
+    if ( numPages <= 1 ) {
+        // Splitting is not necessary, so return a list with one page.
+        list += *this;
+        return list;
+    }
+
+    // Get the number of characters to transmit in each page.
+    int split;
+    uint scheme= dataCodingScheme();
+
+    switch ( scheme ) {
+        case QSMS_UCS2Alphabet:
+            split = 40; break;
+        case QSMS_DefaultAlphabet:
+        default:
+            split = 93; break;
+    }
+
+    // Split the message to create sub-messages and transmit them.
+    int posn = 0;
+    int len;
+    uint number;
+    QCBSMessage tmp;
+    number = 1;
+    QString txt = text();
+    while ( posn < txt.length() ) {
+        tmp = *this;
+        len = txt.length() - posn;
+        if ( len > split ) {
+            len = split;
+        }
+        tmp.setText( txt.mid( posn, len ) );
+        tmp.setPage( number++ );
+        posn += len;
+        list.append(tmp);
+    }
+
+    return list;
+}
diff --git a/src/qcbsmessage.h b/src/qcbsmessage.h
index 0f86e3e..f6ed364 100644
--- a/src/qcbsmessage.h
+++ b/src/qcbsmessage.h
@@ -76,6 +76,9 @@ public:
     QCBSMessage::Language language() const;
     void setLanguage( QCBSMessage::Language lang );
 
+    void setDataCodingScheme(int);
+    int dataCodingScheme() const;
+
     uint page() const;
     void setPage( uint page );
 
@@ -93,6 +96,10 @@ public:
     QByteArray toPdu() const;
     static QCBSMessage fromPdu( const QByteArray& pdu );
 
+    bool shouldSplit() const;
+    QList<QCBSMessage> split() const;
+    void computeSize( uint& numPages, uint& spaceLeftInLast ) const;
+
 private:
     QCBSMessagePrivate *d;
 };
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/7] hardwaremanipulator: Add UCS2 encoding support for CBS message
  2012-06-25 14:37 [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD Philippe Nunes
                   ` (2 preceding siblings ...)
  2012-06-25 14:37 ` [PATCH 3/7] qcbsmessage: Extend QCBSMessage class Philippe Nunes
@ 2012-06-25 14:38 ` Philippe Nunes
  2012-06-25 14:38 ` [PATCH 5/7] hardwaremanipulator: Add multi-page " Philippe Nunes
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:38 UTC (permalink / raw)
  To: ofono

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

---
 src/control.cpp             |    6 ++----
 src/hardwaremanipulator.cpp |   28 +++++++++++++++-------------
 src/hardwaremanipulator.h   |    6 ++++--
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/control.cpp b/src/control.cpp
index 27910c2..89dd294 100644
--- a/src/control.cpp
+++ b/src/control.cpp
@@ -329,12 +329,10 @@ 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(),
+    p->constructCBMessage(ui->leMessageCode->text(),ui->cbGeographicalScope->currentIndex(),
+                       ui->leUpdateNumber->text(),ui->leChannel->text(),ui->cbScheme->currentIndex(),
                        ui->cbLanguage->currentIndex(),ui->leNumPages->text(),ui->lePage->text(),
                        ui->teContent->toPlainText());
-
-    emit unsolicitedCommand(QString("+CBM: ")+QString::number(pdu.length()/2)+'\r'+'\n'+ pdu);
 }
 
 void ControlWidget::sendSMSMessage()
diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp
index 909ce2a..c19b507 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 scheme, int language, const QString &numPages, const QString &page, const QString &content)
 {
 
     bool ok;
@@ -71,7 +71,7 @@ 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;
     }
 
 
@@ -82,7 +82,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,14 +91,9 @@ 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);
@@ -106,7 +101,7 @@ QString HardwareManipulator::constructCBMessage(const QString &messageCode, int
         warning(tr("Invalid number of pages,"),
                 tr("Number of pages  must be 1 hex digit long "
                    "and no larger than F"));
-        return "";
+        return;
     }
 
     uint pag = convertString(page, NIBBLE_MAX,ONE_CHAR,HEX_BASE,&ok);
@@ -114,7 +109,7 @@ QString HardwareManipulator::constructCBMessage(const QString &messageCode, int
         warning(tr("Invalid page number,"),
                 tr("Page number  must be 1 hex digit long "
                    "and no larger than F"));
-        return "";
+        return;
     }
 
     QCBSMessage m;
@@ -123,11 +118,18 @@ QString HardwareManipulator::constructCBMessage(const QString &messageCode, int
     m.setUpdateNumber(un);
     m.setChannel(ch);
     m.setLanguage(lang);
+    m.setDataCodingScheme(scheme == 0 ? QSMS_DefaultAlphabet : QSMS_UCS2Alphabet);
     m.setNumPages(npag);
     m.setPage(pag);
     m.setText(content);
 
-    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..75e0a94 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 scheme, int language, const QString &numPages, const QString &page, 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/7] hardwaremanipulator: Add multi-page support for CBS message
  2012-06-25 14:37 [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD Philippe Nunes
                   ` (3 preceding siblings ...)
  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
  2012-06-22  8:12   ` Denis Kenzior
  2012-06-25 14:38 ` [PATCH 6/7] sms: Extend CBS message formating to use UCS2 scheme Philippe Nunes
  2012-06-25 14:38 ` [PATCH 7/7] hardwaremanipulator: Add USC2 encoding support for USSD Philippe Nunes
  6 siblings, 1 reply; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:38 UTC (permalink / raw)
  To: ofono

[-- 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/7] sms: Extend CBS message formating to use UCS2 scheme
  2012-06-25 14:37 [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD Philippe Nunes
                   ` (4 preceding siblings ...)
  2012-06-25 14:38 ` [PATCH 5/7] hardwaremanipulator: Add multi-page " Philippe Nunes
@ 2012-06-25 14:38 ` 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
  6 siblings, 1 reply; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:38 UTC (permalink / raw)
  To: ofono

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

---
 src/qsmsmessage.cpp |  119 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 111 insertions(+), 8 deletions(-)

diff --git a/src/qsmsmessage.cpp b/src/qsmsmessage.cpp
index 1e2a317..c2eeb29 100644
--- a/src/qsmsmessage.cpp
+++ b/src/qsmsmessage.cpp
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 
 #include <qsmsmessage.h>
+#include <qcbsmessage.h>
 #include "qsmsmessage_p.h"
 #include <qatutils.h>
 #include <qgsmcodec.h>
@@ -2462,6 +2463,93 @@ QSMSMessage QSMSDeliverMessage::unpack(QTextCodec *codec)
     return m;
 }
 
+static void iso639_2_from_language(QCBSMessage::Language lang, char *iso639)
+{
+    switch (lang) {
+    case QCBSMessage::German:
+        iso639[0] = 'd';
+        iso639[1] = 'e';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::English:
+        iso639[0] = 'e';
+        iso639[1] = 'n';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Italian:
+        iso639[0] = 'i';
+        iso639[1] = 't';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::French:
+        iso639[0] = 'f';
+        iso639[1] = 'r';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Spanish:
+        iso639[0] = 'e';
+        iso639[1] = 's';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Dutch:
+        iso639[0] = 'n';
+        iso639[1] = 'l';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Swedish:
+        iso639[0] = 's';
+        iso639[1] = 'v';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Danish:
+        iso639[0] = 'd';
+        iso639[1] = 'a';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Portuguese:
+        iso639[0] = 'p';
+        iso639[1] = 't';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Finnish:
+        iso639[0] = 'f';
+        iso639[1] = 'i';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Norwegian:
+        iso639[0] = 'n';
+        iso639[1] = 'o';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Greek:
+        iso639[0] = 'e';
+        iso639[1] = 'l';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Turkish:
+        iso639[0] = 't';
+        iso639[1] = 'r';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Hungarian:
+        iso639[0] = 'h';
+        iso639[1] = 'u';
+        iso639[2] = '\0';
+        break;
+    case QCBSMessage::Polish:
+        iso639[0] = 'p';
+        iso639[1] = 'l';
+        iso639[2] = '\0';
+        break;
+    default:
+        iso639[0] = '\0';
+        iso639[1] = '\0';
+        iso639[2] = '\0';
+        break;
+    }
+
+    return;
+}
 
 QCBSDeliverMessage::QCBSDeliverMessage()
     : QPDUMessage()
@@ -2518,29 +2606,44 @@ QCBSMessage QCBSDeliverMessage::unpack(QTextCodec *codec)
 
 void QCBSDeliverMessage::pack(const QCBSMessage &m, QSMSDataCodingScheme scheme)
 {
+    int numPad;
+    QTextCodec *codec = QAtUtils::codec( "gsm" );
+    QByteArray header;
+
     // Clear the pdu before we start.
     mBuffer = QByteArray();
     mPosn = 0;
     mBits = 0;
 
-    scheme = QSMS_DefaultAlphabet;
-    QByteArray data;
     mBuffer.append( (char) (((m.messageCode() >> 4) & 0x3F) | (m.scope() << 6)) );
     mBuffer.append( (char)(((m.messageCode() & 0xF) << 4) | (m.updateNumber() & 0xF)) );
     mBuffer.append( (char)((m.channel() & 0x0000FF00) >> 8) );
     mBuffer.append( (char)(m.channel() & 0x000000FF) );
-    mBuffer.append( (char)(((scheme & 0x0F)<<4) | (m.language() & 0x0F)) );
-    mBuffer.append( (char)((m.numPages() & 0x0F) | ((m.page() & 0x0F) << 4)) );
 
-    QTextCodec *codec = QAtUtils::codec( "gsm" );
-    QByteArray header;
+    if (scheme == QSMS_UCS2Alphabet)
+        mBuffer.append( 0x11 );
+    else
+        mBuffer.append( (char)(((scheme & 0x0F)<<4) | (m.language() & 0x0F)) );
+
+    mBuffer.append( (char)((m.numPages() & 0x0F) | ((m.page() & 0x0F) << 4)) );
 
     QString paddedText = m.text();
 
-    int numPad = 93 - getEncodedLength(paddedText, paddedText.length());
+    if (scheme == QSMS_UCS2Alphabet) {
+        char iso639[3];
+        unsigned short c;
+
+        iso639_2_from_language(m.language(), iso639);
+        c = ((iso639[1] & 0x7F)<<7) | (iso639[0] & 0x7F);
+        mBuffer.append( (char)(c & 0xFF) );
+        mBuffer.append( (char)(c >> 8) );
+        numPad = 40 - (paddedText.length());
+    }
+    else
+        numPad = 93 - getEncodedLength(paddedText, paddedText.length());
 
     for (int i = 0; i < numPad; i++)
-    	paddedText.append(QChar(0x0D));
+        paddedText.append(QChar(0x0D));
 
     setUserData(paddedText, scheme, codec, header,true);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 7/7] hardwaremanipulator: Add USC2 encoding support for USSD.
  2012-06-25 14:37 [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD Philippe Nunes
                   ` (5 preceding siblings ...)
  2012-06-25 14:38 ` [PATCH 6/7] sms: Extend CBS message formating to use UCS2 scheme Philippe Nunes
@ 2012-06-25 14:38 ` Philippe Nunes
  2012-06-22 14:09   ` Denis Kenzior
  6 siblings, 1 reply; 14+ messages in thread
From: Philippe Nunes @ 2012-06-25 14:38 UTC (permalink / raw)
  To: ofono

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

---
 src/hardwaremanipulator.cpp |   31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp
index b746229..056480c 100644
--- a/src/hardwaremanipulator.cpp
+++ b/src/hardwaremanipulator.cpp
@@ -320,14 +320,37 @@ void HardwareManipulator::sendVMNotify( int type, int count, const QList<QVMMess
 void HardwareManipulator::sendUSSD( bool cancel, bool response,
 		const QString &content )
 {
-    QTextCodec *codec = QAtUtils::codec( rules->variable("SCS") );
     /* TODO: if rules->variable("USD") == "0" then return */
     if (cancel)
         emit unsolicitedCommand( "+CUSD: 2" );
-    else
+    else {
+        QTextCodec *codec = QAtUtils::codec( "gsm-noloss" );
+        bool gsmSafe;
+        QString request;
+
+        // Check the body for non-GSM characters.
+        gsmSafe = codec->canEncode( content );
+
+        // Use the default alphabet if everything is GSM-compatible.
+        if ( gsmSafe ) {
+            QTextCodec *codec = QAtUtils::codec( rules->variable("SCS") );
+            request= QAtUtils::quote( content, codec );
+        } else {
+            // Encode the text using the 16-bit UCS2 alphabet.
+            uint u;
+            QByteArray binary;
+            uint len = content.length();
+
+            for ( u = 0; u < len; u++ ) {
+                binary += (unsigned char)(content[u].unicode() >> 8);
+                binary += (unsigned char)(content[u].unicode() & 0xFF);
+            }
+            request = PS_toHex( binary );
+        }
         emit unsolicitedCommand( "+CUSD: " +
-                        QString::number( response ? 1 : 0 ) + ",\"" +
-                        QAtUtils::quote( content, codec ) + "\",0" );
+                    QString::number( response ? 1 : 0 ) + ",\"" +
+                    request + "\"," + QString::number( gsmSafe ? 0 : 0x48 ));
+    }
 }
 
 bool HardwareManipulator::getSimPresent()
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-06-25 14:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 5/7] hardwaremanipulator: Add multi-page " Philippe Nunes
2012-06-22  8:12   ` 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

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.