[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [phoneblocker] frontends/blackberry/headless: Process multiple lines from the buffer if there is mor
From:       Laszlo Papp <lpapp () kde ! org>
Date:       2015-01-19 7:44:15
Message-ID: E1YD70R-0003lF-H6 () scm ! kde ! org
[Download RAW message or body]

Git commit 5921eb16e45eefbe0061c76b1a9c3981646d0531 by Laszlo Papp.
Committed on 19/01/2015 at 07:36.
Pushed by lpapp into branch 'master'.

Process multiple lines from the buffer if there is more than one

Otherwise, only the first line would be processed until new data arrives and
only one line processed at best in each "arrival".

M  +33   -33   frontends/blackberry/headless/blocker.cpp

http://commits.kde.org/phoneblocker/5921eb16e45eefbe0061c76b1a9c3981646d0531

diff --git a/frontends/blackberry/headless/blocker.cpp b/frontends/blackberry/headless/blocker.cpp
index 87aa80b..36f2ab8 100644
--- a/frontends/blackberry/headless/blocker.cpp
+++ b/frontends/blackberry/headless/blocker.cpp
@@ -205,40 +205,40 @@ void Blocker::handleNewConnection()
 
 void Blocker::read()
 {
-    if (!m_socket->canReadLine())
-        return;
-    QByteArray data = m_socket->readLine();
-    int sdata = data.size();
-    if (sdata < 3) {
-        qWarning() << "Invalid message";
-        return;
-    }
-    char csms = data.at(0);
-    char ccall = data.at(1);
-    if (sdata == 3) {
-        if (ccall == 'b') blockPrivateCall();
-        else if (ccall == 'u') unblockPrivateCall();
-    } else if (sdata == 4) {
-        char phoneNumber = data.at(2);
-        if (csms == 'b') {
-            if (phoneNumber == 'a') blockAllSms();
-            else if (phoneNumber == 'c') blockOutsideContactsSms();
-        } else if (csms == 'u') {
-            if (phoneNumber == 'a') unblockAllSms();
-            else if (phoneNumber == 'c') unblockOutsideContactsSms();
+    while (m_socket->canReadLine()) {
+        QByteArray data = m_socket->readLine();
+        int sdata = data.size();
+        if (sdata < 3) {
+            qWarning() << "Invalid message";
+            return;
         }
-        if (ccall == 'b') {
-            if (phoneNumber == 'a') blockAllCall();
-            else if (phoneNumber == 'c') blockOutsideContactsCall();
-        } else if (csms == 'u') {
-            if (phoneNumber == 'a') unblockAllCall();
-            else if (phoneNumber == 'c') unblockOutsideContactsCall();
+        char csms = data.at(0);
+        char ccall = data.at(1);
+        if (sdata == 3) {
+            if (ccall == 'b') blockPrivateCall();
+            else if (ccall == 'u') unblockPrivateCall();
+        } else if (sdata == 4) {
+            char phoneNumber = data.at(2);
+            if (csms == 'b') {
+                if (phoneNumber == 'a') blockAllSms();
+                else if (phoneNumber == 'c') blockOutsideContactsSms();
+            } else if (csms == 'u') {
+                if (phoneNumber == 'a') unblockAllSms();
+                else if (phoneNumber == 'c') unblockOutsideContactsSms();
+            }
+            if (ccall == 'b') {
+                if (phoneNumber == 'a') blockAllCall();
+                else if (phoneNumber == 'c') blockOutsideContactsCall();
+            } else if (csms == 'u') {
+                if (phoneNumber == 'a') unblockAllCall();
+                else if (phoneNumber == 'c') unblockOutsideContactsCall();
+            }
+        } else {
+            QByteArray phoneNumber = data.mid(2, sdata-3);
+            if (csms == 'b') blockSms(phoneNumber);
+            else if (csms == 'u') unblockSms(phoneNumber);
+            if (ccall == 'b') blockCall(phoneNumber);
+            else if (ccall == 'u') unblockCall(phoneNumber);
         }
-    } else {
-        QByteArray phoneNumber = data.mid(2, sdata-3);
-        if (csms == 'b') blockSms(phoneNumber);
-        else if (csms == 'u') unblockSms(phoneNumber);
-        if (ccall == 'b') blockCall(phoneNumber);
-        else if (ccall == 'u') unblockCall(phoneNumber);
     }
 }

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic