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

List:       kde-commits
Subject:    kdepim/kandy/src [POSSIBLY UNSAFE]
From:       Heiko Falk <Heiko.Falk () udo ! edu>
Date:       2004-11-16 12:37:18
Message-ID: 20041116123718.6ECFD16D07 () office ! kde ! org
[Download RAW message or body]

CVS commit by hfalk: 

+ Now using the string specified in the configuration dialog in order to
  place the modem LOCK file in a non-hardcoded directory.
+ The kprefs object now is passed to the modem constructors so that every
  change within the preferences now is immediately visible in the modem
  class.


  M +9 -23     modem.cpp   1.8 [POSSIBLY UNSAFE: printf]


--- kdepim/kandy/src/modem.cpp  #1.7:1.8
@@ -49,7 +49,4 @@
 
 
-#define LOCK_PATH "/var/lock"
-
-
 #ifndef CSOH
 #define CSOH  01
@@ -78,8 +75,10 @@
 
 
-Modem::Modem(QObject *parent, const char *name) : QObject(parent, name)
+Modem::Modem(KandyPrefs *kprefs, QObject *parent, const char *name) : QObject(parent, name)
 {
   mOpen = false;
 
+  prefs = kprefs;
+
         timer = new QTimer(this, "modemtimer");
         Q_CHECK_PTR(timer);
@@ -97,13 +96,4 @@ Modem::~Modem()
 
 
-void Modem::setDevice(const QString& name)
-{
-        if (fdev)
-                free(fdev);
-
-        fdev = strdup(name.latin1());
-}
-
-
 void Modem::setSpeed(int speed)
 {
@@ -133,19 +123,13 @@ void Modem::setSpeed(int speed)
                         cspeed = B38400;
                         break;
-#ifdef B57600
                 case 57600:
                         cspeed = B57600;
                         break;
-#endif
-#ifdef B115200
                 case 115200:
                         cspeed = B115200;
                         break;
-#endif
-#ifdef B230400
                 case 230400:
                         cspeed = B230400;
                         break;
-#endif
                 default:
 #ifdef MODEM_DEBUG
@@ -207,4 +191,5 @@ bool Modem::open()
         }
 
+        char *fdev = strdup((*prefs).serialDevice().latin1());
         if ((fd = ::open(fdev, O_RDWR | O_NOCTTY | O_NONBLOCK)) == -1) {
           emit errorMessage( i18n("Unable to open device '%1'. "
@@ -289,4 +274,5 @@ bool Modem::lockDevice()
                 return true;
 
+        char *fdev = strdup((*prefs).serialDevice().latin1());
         if ((p = strrchr(fdev, '/')))
                 p++;
@@ -294,5 +280,5 @@ bool Modem::lockDevice()
                 p = fdev;
 
-        sprintf(fname, "%s/LCK..%s", LOCK_PATH, p);
+        sprintf(fname, "%s/LCK..%s", (*prefs).lockDirectory().latin1(), p);
         if (!access(fname, F_OK)) {
                 if ((lfd = ::open(fname, O_RDONLY)) < 0) {
@@ -356,4 +342,5 @@ void Modem::unlockDevice()
 
         if (is_locked) {
+                char *fdev = strdup((*prefs).serialDevice().latin1());
                 if ((p = strrchr(fdev, '/')))
                         p++;
@@ -361,5 +348,5 @@ void Modem::unlockDevice()
                         p = fdev;
 
-                sprintf(fname, "%s/LCK..%s", LOCK_PATH, p);
+                sprintf(fname, "%s/LCK..%s", (*prefs).lockDirectory().latin1(), p);
                 unlink(fname);
                 is_locked = false;
@@ -420,5 +407,5 @@ void Modem::writeChar(const char c)
 void Modem::writeLine(const char *line)
 {
-  kdDebug(5960) << "Modem::writeLine(): " << line << endl;
+  kdDebug() << "Modem::writeLine(): " << line << endl;
 
         write(fd, (const void *)line, strlen(line));
@@ -631,5 +618,4 @@ void Modem::init()
         is_locked = false;
 
-        fdev = 0;
         fd = 0;
         sn = 0;


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

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