Changes: Temporary booster process name defined and initialized in

booster classes as a static variable. Getters added.

RevBy: Antti Kervinen

Details: Temporary booster process name was previously generated from
the type char at the time process was renamed. This made it impossible
to use the temporary process name from other classes.
pull/1/head
Jussi Lind 15 years ago
parent 4f8880ac0f
commit 933faa51ad

@ -122,11 +122,7 @@ void Booster::renameProcess(int parentArgc, char** parentArgv)
{ {
// application name isn't known yet, let's give to the process // application name isn't known yet, let's give to the process
// temporary booster name // temporary booster name
m_app.setAppName(boosterTemporaryProcessName());
string newProcessName("booster-");
newProcessName.append(1, boosterType());
m_app.setAppName(newProcessName);
} }
const char* newProcessName = m_app.appName().c_str(); const char* newProcessName = m_app.appName().c_str();

@ -98,6 +98,12 @@ public:
*/ */
virtual char boosterType() const = 0; virtual char boosterType() const = 0;
/*! Return the process name to be used when booster is not
* yet transformed into a running application (e.g. "booster-m"
* for MBooster)
*/
virtual const string & boosterTemporaryProcessName() const = 0;
//! Set nice value and store the old priority. Return true on success. //! Set nice value and store the old priority. Return true on success.
bool pushPriority(int nice); bool pushPriority(int nice);

@ -219,8 +219,8 @@ void Daemon::forkKiller()
BoosterKiller bk; BoosterKiller bk;
bk.addKey("/meegotouch/theme/name"); bk.addKey("/meegotouch/theme/name");
bk.addKey("/meegotouch/i18n/language"); bk.addKey("/meegotouch/i18n/language");
bk.addProcessName("booster-m"); bk.addProcessName(MBooster::temporaryProcessName().c_str());
bk.addProcessName("booster-w"); bk.addProcessName(WRTBooster::temporaryProcessName().c_str());
bk.start(); // does not return. bk.start(); // does not return.
} }
} }

@ -25,16 +25,9 @@
#endif #endif
const string MBooster::m_socketId = "/tmp/boostm"; const string MBooster::m_socketId = "/tmp/boostm";
const string MBooster::m_temporaryProcessName = "booster-m";
int MBooster::m_ProcessID = 0; int MBooster::m_ProcessID = 0;
MBooster::MBooster()
{
}
MBooster::~MBooster()
{
}
const string & MBooster::socketId() const const string & MBooster::socketId() const
{ {
return m_socketId; return m_socketId;
@ -53,6 +46,16 @@ const string & MBooster::socketName()
return m_socketId; return m_socketId;
} }
const string & MBooster::temporaryProcessName()
{
return m_temporaryProcessName;
}
const string & MBooster::boosterTemporaryProcessName() const
{
return temporaryProcessName();
}
char MBooster::type() char MBooster::type()
{ {
return 'm'; return 'm';

@ -36,10 +36,10 @@ class MBooster : public Booster
public: public:
//! \brief Constructor //! \brief Constructor
MBooster(); MBooster() {};
//! \brief Destructor //! \brief Destructor
virtual ~MBooster(); virtual ~MBooster() {};
//! \reimp //! \reimp
virtual bool preload(); virtual bool preload();
@ -50,6 +50,13 @@ public:
*/ */
static const string & socketName(); static const string & socketName();
//! Return the process name to be used when booster is not
//! yet transformed into a running application
static const string & temporaryProcessName();
//! \reimp
virtual const string & boosterTemporaryProcessName() const;
//! \reimp //! \reimp
virtual char boosterType() const { return type(); } virtual char boosterType() const { return type(); }
@ -86,6 +93,10 @@ private:
static int m_ProcessID; static int m_ProcessID;
//! Process name to be used when booster is not
//! yet transformed into a running application
static const string m_temporaryProcessName;
#ifdef UNIT_TEST #ifdef UNIT_TEST
friend class Ut_MBooster; friend class Ut_MBooster;
#endif #endif

@ -20,24 +20,27 @@
#include "qtbooster.h" #include "qtbooster.h"
const string QtBooster::m_socketId = "/tmp/boostq"; const string QtBooster::m_socketId = "/tmp/boostq";
const string QtBooster::m_temporaryProcessName = "booster-q";
int QtBooster::m_ProcessID = 0; int QtBooster::m_ProcessID = 0;
QtBooster::QtBooster() const string & QtBooster::socketId() const
{ {
return m_socketId;
} }
QtBooster::~QtBooster() const string & QtBooster::socketName()
{ {
return m_socketId;
} }
const string & QtBooster::socketId() const const string & QtBooster::temporaryProcessName()
{ {
return m_socketId; return m_temporaryProcessName;
} }
const string & QtBooster::socketName() const string & QtBooster::boosterTemporaryProcessName() const
{ {
return m_socketId; return temporaryProcessName();
} }
char QtBooster::type() char QtBooster::type()

@ -31,10 +31,10 @@ class QtBooster : public Booster
public: public:
//! Constructor. //! Constructor.
QtBooster(); QtBooster() {};
//! Destructor. //! Destructor.
virtual ~QtBooster(); virtual ~QtBooster() {};
/*! /*!
* \brief Return the socket name common to all QtBooster objects. * \brief Return the socket name common to all QtBooster objects.
@ -42,6 +42,13 @@ public:
*/ */
static const string & socketName(); static const string & socketName();
//! Return the process name to be used when booster is not
//! yet transformed into a running application
static const string & temporaryProcessName();
//! \reimp
virtual const string & boosterTemporaryProcessName() const;
//! \reimp //! \reimp
virtual char boosterType() const { return type(); } virtual char boosterType() const { return type(); }
@ -81,6 +88,9 @@ private:
static int m_ProcessID; static int m_ProcessID;
//! Process name to be used when booster is not
//! yet transformed into a running application
static const string m_temporaryProcessName;
#ifdef UNIT_TEST #ifdef UNIT_TEST
friend class Ut_QtBooster; friend class Ut_QtBooster;

@ -25,16 +25,9 @@
#endif #endif
const string WRTBooster::m_socketId = "/tmp/boostw"; const string WRTBooster::m_socketId = "/tmp/boostw";
const string WRTBooster::m_temporaryProcessName = "booster-w";
int WRTBooster::m_ProcessID = 0; int WRTBooster::m_ProcessID = 0;
WRTBooster::WRTBooster()
{
}
WRTBooster::~WRTBooster()
{
}
const string & WRTBooster::socketId() const const string & WRTBooster::socketId() const
{ {
return m_socketId; return m_socketId;
@ -53,6 +46,16 @@ const string & WRTBooster::socketName()
return m_socketId; return m_socketId;
} }
const string & WRTBooster::temporaryProcessName()
{
return m_temporaryProcessName;
}
const string & WRTBooster::boosterTemporaryProcessName() const
{
return temporaryProcessName();
}
char WRTBooster::type() char WRTBooster::type()
{ {
return 'w'; return 'w';

@ -35,10 +35,10 @@ class WRTBooster : public Booster
public: public:
//! \brief Constructor //! \brief Constructor
WRTBooster(); WRTBooster() {};
//! \brief Destructor //! \brief Destructor
virtual ~WRTBooster(); virtual ~WRTBooster() {};
//! \reimp //! \reimp
virtual bool preload(); virtual bool preload();
@ -49,6 +49,13 @@ public:
*/ */
static const string & socketName(); static const string & socketName();
//! Return the process name to be used when booster is not
//! yet transformed into a running application
static const string & temporaryProcessName();
//! \reimp
virtual const string & boosterTemporaryProcessName() const;
//! \reimp //! \reimp
virtual char boosterType() const { return type(); } virtual char boosterType() const { return type(); }
@ -85,6 +92,10 @@ private:
static int m_ProcessID; static int m_ProcessID;
//! Process name to be used when booster is not
//! yet transformed into a running application
static const string m_temporaryProcessName;
#ifdef UNIT_TEST #ifdef UNIT_TEST
friend class Ut_WRTBooster; friend class Ut_WRTBooster;
#endif #endif

@ -20,25 +20,34 @@
#include "ut_booster.h" #include "ut_booster.h"
#include "booster.h" #include "booster.h"
// Booster is an abstract base-class, so let's inherit it // Booster is an abstract base-class, so let's inherit it and
// define methods that are pure virtual
class MyBooster : public Booster class MyBooster : public Booster
{ {
public: public:
MyBooster(); MyBooster();
char boosterType() const; char boosterType() const;
const std::string & socketId() const; const std::string & socketId() const;
const std::string & boosterTemporaryProcessName() const;
private: private:
const string m_socketId; const string m_socketId;
const string m_temporaryProcessName;
}; };
MyBooster::MyBooster() : MyBooster::MyBooster() :
m_socketId("/tmp/MyBooster") m_socketId("/tmp/MyBooster"),
m_temporaryProcessName("x-booster")
{} {}
char MyBooster::boosterType() const char MyBooster::boosterType() const
{ {
return 'm'; return 'x';
}
const std::string & MyBooster::boosterTemporaryProcessName() const
{
return m_temporaryProcessName;
} }
const std::string & MyBooster::socketId() const const std::string & MyBooster::socketId() const
@ -46,12 +55,6 @@ const std::string & MyBooster::socketId() const
return m_socketId; return m_socketId;
} }
Ut_Booster::Ut_Booster()
{}
Ut_Booster::~Ut_Booster()
{}
void Ut_Booster::initTestCase() void Ut_Booster::initTestCase()
{} {}
@ -87,7 +90,7 @@ void Ut_Booster::testRenameBoosterProcess()
m_subject->renameProcess(INIT_ARGS, const_cast<char **>(initialArgv)); m_subject->renameProcess(INIT_ARGS, const_cast<char **>(initialArgv));
// New name and arguments fit and are correct // New name and arguments fit and are correct
QVERIFY(strcmp(initialArgv[0], "booster-m") == 0); QVERIFY(strcmp(initialArgv[0], m_subject->boosterTemporaryProcessName().c_str()) == 0);
// Define and copy args because it's assumed that they are allocated in the heap // Define and copy args because it's assumed that they are allocated in the heap
// (AppData deletes the argv on exit) // (AppData deletes the argv on exit)

@ -33,10 +33,6 @@ class Ut_Booster : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
Ut_Booster();
virtual ~Ut_Booster();
private Q_SLOTS: private Q_SLOTS:
void initTestCase(); void initTestCase();
void testRenameProcess(); void testRenameProcess();

Loading…
Cancel
Save