Hello,

this patch adds an optional phone number parameter to ofono-phonesim, instead 
of using the default number.

Greetings
Bettina

Michael Klemm:
Added phone number as additional parameter (1/2)
AUTHORS: Mention Michael's contributions      (2/2)

(1/2)
diff --git a/src/main.cpp b/src/main.cpp
index 712e767..a20bc1a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,13 +28,14 @@ static void usage()
{
     qWarning() << "Usage:"
                << 
QFileInfo(QCoreApplication::instance()->applicationFilePath()).fileName().toLocal8Bit().constData()
-               << "[-v] [-p port] [-gui] filename";
+               << "[-v] [-p port] [-gui] [-n number] filename";
     exit(-1);
}
 int main(int argc, char **argv)
{
     QString filename = nullptr;
+    QString number = "+491701234567";
     QCoreApplication *app;
     int port = 12345;
     int index;
@@ -61,6 +62,15 @@ int main(int argc, char **argv)
         } else if ( strcmp(argv[index],"-h") == 0
                 || strcmp(argv[index],"-help") == 0 ) {
             usage();
+        } else if ( strcmp(argv[index],"-n") == 0
+                || strcmp(argv[index],"-num") == 0 ) {
+            index++;
+            if (index >= argc) {
+                qWarning() << "ERROR: Got -n but missing phone number";
+                usage();
+            } else {
+                number = argv[index];
+            }
         } else {
             // must be filename.  SHOULD be last argument.
             if (index != argc-1) {
@@ -85,7 +95,7 @@ int main(int argc, char **argv)
     } else
         app = new QCoreApplication(argc, argv);
-    PhoneSimServer *pss = new PhoneSimServer(filename, port, nullptr);
+    PhoneSimServer *pss = new PhoneSimServer(filename, port, number, nullptr);

diff --git a/src/server.cpp b/src/server.cpp
index 3ff7def..856a90f 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -22,13 +22,12 @@
#include "hardwaremanipulator.h"
#include <qdebug.h>
-static int phonenumber = 555000;
-
-PhoneSimServer::PhoneSimServer(const QString &f, quint16 port, QObject *parent)
+PhoneSimServer::PhoneSimServer(const QString &f, quint16 port, const QString 
&n, QObject *parent)
     : QTcpServer(parent), fact(nullptr), currentRules(nullptr)
{
     listen( QHostAddress::Any, port );
     filename = f;
+    number = n;
}
 PhoneSimServer::~PhoneSimServer()
@@ -47,7 +46,6 @@ void 
PhoneSimServer::setHardwareManipulator(HardwareManipulatorFactory *f)
void PhoneSimServer::incomingConnection(qintptr s)
{
   SimRules *sr = new SimRules(s, this, filename, fact);
-    sr->setPhoneNumber(QString::number(phonenumber));
-    phonenumber++;
+    sr->setPhoneNumber(number);
     currentRules = sr;
}

diff --git a/src/server.h b/src/server.h
index 9175359..6790be4 100644
--- a/src/server.h
+++ b/src/server.h
@@ -32,7 +32,7 @@ class HardwareManipulatorFactory;
class PhoneSimServer : public QTcpServer
{
public:
-    PhoneSimServer(const QString &, quint16 port, QObject *parent = nullptr);
+    PhoneSimServer(const QString &, quint16 port, const QString &, QObject 
*parent = nullptr);
     ~PhoneSimServer() override;
     void setHardwareManipulator(HardwareManipulatorFactory *f);
@@ -44,6 +44,7 @@ protected:
 private:
     QString filename;
+    QString number;



(2/2)
diff --git a/AUTHORS b/AUTHORS
index 9b8a840..d8e107f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -15,3 +15,4 @@ Jussi Pakkanen <[email protected]>
James Prestwood <[email protected]>
Simon Busch <[email protected]>
Jonah Brüchert <[email protected]>
+Michael Klemm <[email protected]>
_____________________________________________________________________________________

Expleo Germany GmbH
Sitz der Gesellschaft | Corporate Headquarters: München
Handelsregister | Commercial Register: Amtsgericht München HRB 83252
Geschäftsführung | Management: Ralph Gillessen, Josef Mitterhuber

This message contains information that may be privileged or confidential. It is 
intended only for the person to whom it is addressed.
If you are not the intended recipient, you are not authorized to read, print, 
retain, copy, disseminate, distribute, or use this message or any part thereof.
If you receive this message in error, please notify the sender immediately and 
delete all copies of this message.
_________________________________________________________

EMAIL LEGAL MENTION / DISCLAIMER

This message contains information that may be privileged or confidential and is 
the property of the Expleo Services SAS, RCS Versailles 831 178 348, located, 3 
avenue des Prés, 78180 Montigny Le Bretonneux - France. It is intended only for 
the person to whom it is addressed. If you are not the intended recipient, you 
are not authorized to read, print, retain, copy, disseminate, distribute, or 
use this message or any part thereof. If you receive this message in error, 
please notify the sender immediately and delete all copies of this message.

Ce message contient des informations qui peuvent être privilégiées ou 
confidentielles et elles sont de la propriété d'Expleo Services SAS, RCS 
Versailles 831 178 348, situé, 3 avenue des Prés, 78180 Montigny le 
Bretonneux-France. Il est destiné uniquement à la personne à qui est adressé. 
Si vous n'êtes pas le destinataire visé, vous n'êtes pas autorisé à lire, 
imprimer, conserver, copier, diffuser, distribuer ou utiliser ce message ou 
toute partie de celui-ci. Si vous recevez ce message par erreur, veuillez en 
avertir immédiatement l'expéditeur et supprimer toutes les copies de ce message.
_______________________________________________
ofono mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to