mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
add launcher improvment and window movement
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
2006-08-31 Yan Morin
|
||||
|
||||
* Improve launcher (only start if needed). If the daemon is started, qt won't stop it.
|
||||
|
||||
* Fix buf with microphone (if the mic wasn't at 100, it causes a segfault before)
|
||||
|
||||
2006-08-31 Yan Morin
|
||||
|
||||
* Add samplerate combobox if sample rate is compiled
|
||||
|
@ -52,7 +52,7 @@
|
||||
void ConfigurationPanel::init()
|
||||
{
|
||||
_cutStringCombo = 30;
|
||||
DebugOutput::instance() << "ConfigurationPanel::init()\n";
|
||||
//DebugOutput::instance() << "ConfigurationPanel::init()\n";
|
||||
lblError->hide();
|
||||
Tab_Signalisations->show();
|
||||
Tab_Audio->hide();
|
||||
@ -339,7 +339,7 @@ void ConfigurationPanel::updateAudioDevices()
|
||||
if (hostApiName.length() > _cutStringCombo) {
|
||||
hostApiName = hostApiName.left(_cutStringCombo) + "...";
|
||||
}
|
||||
DebugOutput::instance() << hostApiName << pos->defaultRate;
|
||||
//DebugOutput::instance() << hostApiName << pos->defaultRate;
|
||||
QString name = hostApiName + QObject::tr(" (device #%1-%2Hz)").arg(pos->index).arg(pos->defaultRate);
|
||||
cbo->insertItem(name);
|
||||
}
|
||||
@ -421,7 +421,7 @@ ConfigurationPanel::slotSIPAccountChange(int index)
|
||||
if (lastSIPAccount!=index) {
|
||||
|
||||
QString account = "SIP" + QString::number(index);
|
||||
DebugOutput::instance() << "Selecting SIP account " << account << "\n";
|
||||
//DebugOutput::instance() << "Selecting SIP account " << account << "\n";
|
||||
|
||||
saveSIPAccount(lastSIPAccount);
|
||||
loadSIPAccount(index);
|
||||
|
@ -17,6 +17,7 @@ BUILT_SOURCES = \
|
||||
./SFLPhoneWindowmoc.cpp \
|
||||
./SFLRequestmoc.cpp \
|
||||
./Requestmoc.cpp \
|
||||
./Sessionmoc.cpp \
|
||||
./SessionIOmoc.cpp \
|
||||
./TCPSessionIOmoc.cpp \
|
||||
./TransparentWidgetmoc.cpp \
|
||||
|
@ -237,15 +237,16 @@ NumericKeypad::mouseMoveEvent(QMouseEvent *e)
|
||||
// DebugOutput::instance() << "mWinRef (x1,y1): " << wx1 << " " << wy1 << "\n";
|
||||
|
||||
// x and y
|
||||
if (abs(px0-wx1) <= range) { pt.setX(wx1); }
|
||||
else if (abs(px1-wx0) <= range) { pt.setX(wx0-width()); }
|
||||
mIsDock = false;
|
||||
if (abs(px0-wx1) <= range) { pt.setX(wx1); mIsDock = true; }
|
||||
else if (abs(px1-wx0) <= range) { pt.setX(wx0-width()); mIsDock = true; }
|
||||
|
||||
// top and down
|
||||
if (abs(py0-wy0) <= range) { pt.setY(wy0); }
|
||||
// the numeric under the telephone
|
||||
else if (abs(py0-wy1) <= range) { pt.setY(wy1); }
|
||||
else if (abs(py0-wy1) <= range) { pt.setY(wy1); mIsDock = true;}
|
||||
// the numeric over the telephone
|
||||
else if (abs(py1-wy0) <= range) { pt.setY(wy0-height()); }
|
||||
else if (abs(py1-wy0) <= range) { pt.setY(wy0-height()); mIsDock = true;}
|
||||
}
|
||||
|
||||
move(pt);
|
||||
@ -311,6 +312,7 @@ void
|
||||
NumericKeypad::setDefaultPosition(const QPoint& point) {
|
||||
if (mWinRef && !mAlreadySet) {
|
||||
move(point);
|
||||
mIsDock = true;
|
||||
mAlreadySet = true;
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
/** Set default position of the window */
|
||||
void setDefaultPosition(const QPoint&);
|
||||
void setWindowReference(QWidget* widget) { mWinRef = widget; }
|
||||
bool isDock() { return mIsDock; }
|
||||
|
||||
public slots:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
@ -84,6 +85,7 @@ private:
|
||||
/** Window reference when moving the window (magnetic style) */
|
||||
QWidget* mWinRef;
|
||||
bool mAlreadySet; // already set the default position or not?
|
||||
bool mIsDock; // beside the ref window or not?
|
||||
};
|
||||
|
||||
#endif // __NUMERIC_KEYPAD_H__
|
||||
|
@ -44,6 +44,7 @@ PhoneLineManagerImpl::PhoneLineManagerImpl()
|
||||
, mMicVolume(-1)
|
||||
, mIsConnected(false)
|
||||
, mIsStopping(false)
|
||||
, mShouldStopDaemon(false)
|
||||
, mLastNumber("")
|
||||
{
|
||||
EventFactory::instance().registerDefaultEvent< DefaultEvent >();
|
||||
@ -191,7 +192,12 @@ PhoneLineManagerImpl::stop()
|
||||
emit globalStatusSet(QString(tr("Stopping sflphone server..")));
|
||||
mIsStopping = true;
|
||||
if(mIsConnected) {
|
||||
mSession->stop();
|
||||
if (mShouldStopDaemon) {
|
||||
mSession->stop();
|
||||
emit stopped();
|
||||
} else {
|
||||
mSession->quit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
emit stopped();
|
||||
|
@ -62,11 +62,13 @@ public:
|
||||
PhoneLine *getCurrentLine();
|
||||
|
||||
void setNbLines(unsigned int line);
|
||||
void shouldStopDaemon(bool shouldStop) { mShouldStopDaemon = shouldStop; }
|
||||
|
||||
bool isConnected() { return mIsConnected; }
|
||||
void emitReadyAccount() { emit readyToGetAccount(); }
|
||||
void emitReadyToShow() { emit readyToShow(); }
|
||||
void addAccount(const QString& name, bool isEnabled, const QString& alias);
|
||||
|
||||
signals:
|
||||
void unselected(unsigned int);
|
||||
void selected(unsigned int);
|
||||
@ -352,6 +354,7 @@ private:
|
||||
|
||||
bool mIsConnected;
|
||||
bool mIsStopping;
|
||||
bool mShouldStopDaemon;
|
||||
|
||||
QString mLastNumber;
|
||||
};
|
||||
|
@ -110,12 +110,12 @@ Request::onEntry(const QString &code, const QString &message)
|
||||
void
|
||||
Request::onSuccess(const QString &code, const QString &message)
|
||||
{
|
||||
DebugOutput::instance() << QObject::tr("Received a success info: "
|
||||
"Code/SeqID: %1/%2\t"
|
||||
"Message: %3\n")
|
||||
.arg(code)
|
||||
.arg(mSequenceId)
|
||||
.arg(message);
|
||||
// DebugOutput::instance() << QObject::tr("Received a success info: "
|
||||
// "Code/SeqID: %1/%2\t"
|
||||
// "Message: %3\n")
|
||||
// .arg(code)
|
||||
// .arg(mSequenceId)
|
||||
// .arg(message);
|
||||
QString messageDecoded = message;
|
||||
Url::decode(messageDecoded);
|
||||
|
||||
|
@ -47,11 +47,14 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv)
|
||||
SessionIOFactory::instance().setCreator(new TCPSessionIOCreator(QString("localhost"), 3999));
|
||||
|
||||
mSession = new Session();
|
||||
connect(mSession, SIGNAL(firstSessionIOConnectionFailed()), this, SLOT(launch()));
|
||||
|
||||
ConfigurationManager::instance().setSession(mSession);
|
||||
|
||||
PhoneLineManager::instance().initialize(mSession);
|
||||
PhoneLineManager::instance().setNbLines(NB_PHONELINES);
|
||||
PhoneLineManager::instance().shouldStopDaemon(false);
|
||||
|
||||
Requester::instance().registerDefaultObject< Request >();
|
||||
Requester::instance().registerObject< Request >(QString("playtone"));
|
||||
Requester::instance().registerObject< Request >(QString("stoptone"));
|
||||
@ -97,6 +100,7 @@ void
|
||||
SFLPhoneApp::launch()
|
||||
{
|
||||
if(mLauncher) {
|
||||
PhoneLineManager::instance().shouldStopDaemon(true);
|
||||
mLauncher->start();
|
||||
}
|
||||
}
|
||||
@ -206,8 +210,7 @@ SFLPhoneApp::initConnections(SFLPhoneWindow *w)
|
||||
QObject::connect(&PhoneLineManager::instance(), SIGNAL(readyToShow()), w, SLOT(show()));
|
||||
QObject::connect(w, SIGNAL(reconnectAsked()),
|
||||
&PhoneLineManager::instance(), SLOT(connect()));
|
||||
QObject::connect(&PhoneLineManager::instance(), SIGNAL(stopped()),
|
||||
w, SLOT(close()));
|
||||
QObject::connect(&PhoneLineManager::instance(), SIGNAL(stopped()), w, SLOT(close()));
|
||||
QObject::connect(w, SIGNAL(needToCloseDaemon()),
|
||||
&PhoneLineManager::instance(), SLOT(stop()));
|
||||
|
||||
|
@ -50,7 +50,6 @@ public:
|
||||
void initConnections(SFLPhoneWindow *w);
|
||||
void loadSkin();
|
||||
|
||||
void launch();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
@ -60,6 +59,9 @@ public slots:
|
||||
void paste();
|
||||
void shortcutPressed(QKeyEvent* e);
|
||||
|
||||
private slots:
|
||||
void launch();
|
||||
|
||||
signals:
|
||||
void registerFailed(const QString);
|
||||
void registerSucceed(const QString);
|
||||
|
@ -268,7 +268,13 @@ void
|
||||
SFLPhoneWindow::delayedPaint()
|
||||
{
|
||||
if(pos() != mLastWindowPos) {
|
||||
if (mLastWindowPos.x() < 0) { mLastWindowPos.setX(0); }
|
||||
QPoint diff = mLastWindowPos - pos();
|
||||
move(mLastWindowPos);
|
||||
if (mKeypad && mKeypad->isDock()) {
|
||||
// Use (mKeypad->pos() - diff) for a cool effects
|
||||
mKeypad->move(mKeypad->pos() + diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ Session::Session()
|
||||
{
|
||||
mId = Requester::instance().generateSessionId();
|
||||
SessionIO *s = SessionIOFactory::instance().create();
|
||||
QObject::connect(s, SIGNAL(firstConnectionFailed()), this, SIGNAL(firstSessionIOConnectionFailed()));
|
||||
Requester::instance().registerSession(mId, s);
|
||||
}
|
||||
|
||||
@ -109,9 +110,9 @@ Session::configSave() const
|
||||
}
|
||||
|
||||
Request *
|
||||
Session::close() const
|
||||
Session::quit() const
|
||||
{
|
||||
return Requester::instance().send(mId, "close", std::list< QString >());
|
||||
return Requester::instance().send(mId, "quit", std::list< QString >());
|
||||
}
|
||||
|
||||
Request *
|
||||
|
@ -22,17 +22,20 @@
|
||||
#ifndef SFLPHONEGUI_SESSION_H
|
||||
#define SFLPHONEGUI_SESSION_H
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <map>
|
||||
|
||||
#include "Account.hpp"
|
||||
|
||||
class Session
|
||||
class Session : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Session();
|
||||
Session(const QString &id);
|
||||
~Session();
|
||||
virtual ~Session();
|
||||
|
||||
/**
|
||||
* retreive the account identified by name.
|
||||
@ -91,7 +94,7 @@ class Session
|
||||
* the session. This will only close the session,
|
||||
* so sflphoned will still be running after.
|
||||
*/
|
||||
Request *close() const;
|
||||
Request *quit() const;
|
||||
|
||||
/**
|
||||
* This function will register with the default account.
|
||||
@ -139,6 +142,10 @@ class Session
|
||||
Request *stopTone() const;
|
||||
Request *playTone() const;
|
||||
|
||||
signals:
|
||||
void firstSessionIOConnectionFailed();
|
||||
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
QString mSelectedAccountId;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
|
||||
* Author: Jean-Philippe Barrette-LaPierre
|
||||
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
|
||||
@ -32,7 +32,7 @@ class SessionIO : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual ~SessionIO(){}
|
||||
|
||||
public slots:
|
||||
@ -53,6 +53,8 @@ public slots:
|
||||
*/
|
||||
virtual void receive(QString &answer) = 0;
|
||||
|
||||
signals:
|
||||
void firstConnectionFailed();
|
||||
};
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ TCPSessionIO::TCPSessionIO(const QString &hostname, Q_UINT16 port)
|
||||
, mHostname(hostname)
|
||||
, mPort(port)
|
||||
, mNbConnectTries(0)
|
||||
, mNbConnectTriesTotal(0)
|
||||
{
|
||||
mReconnectTimer = new QTimer(this);
|
||||
QObject::connect(mReconnectTimer, SIGNAL(timeout()),
|
||||
@ -61,15 +62,20 @@ TCPSessionIO::resetConnectionTries()
|
||||
void
|
||||
TCPSessionIO::error(int err)
|
||||
{
|
||||
mNbConnectTries++;
|
||||
if(mNbConnectTries >= NB_MAX_TRIES) {
|
||||
DebugOutput::instance() << QObject::tr("TCPSessionIO: Connection failed: %1\n")
|
||||
.arg(err);
|
||||
mNbConnectTries = 0;
|
||||
emit disconnected();
|
||||
}
|
||||
else {
|
||||
mReconnectTimer->start(2000, true);
|
||||
if (mNbConnectTriesTotal == 0) {
|
||||
emit firstConnectionFailed();
|
||||
mReconnectTimer->start(4000, true);
|
||||
mNbConnectTriesTotal++;
|
||||
} else {
|
||||
mNbConnectTriesTotal++;
|
||||
mNbConnectTries++;
|
||||
if(mNbConnectTries >= NB_MAX_TRIES) {
|
||||
DebugOutput::instance() << QObject::tr("TCPSessionIO: Connection failed: %1\n").arg(err);
|
||||
mNbConnectTries = 0;
|
||||
emit disconnected();
|
||||
} else {
|
||||
mReconnectTimer->start(2000, true);
|
||||
}
|
||||
}
|
||||
//mSocket->close();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
|
||||
* Author: Jean-Philippe Barrette-LaPierre
|
||||
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
|
||||
@ -80,7 +80,7 @@ public slots:
|
||||
|
||||
void resetConnectionTries();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
/**
|
||||
* This function is called when we have an error
|
||||
* on the socket.
|
||||
@ -94,6 +94,7 @@ private:
|
||||
|
||||
std::list< QString > mStack;
|
||||
|
||||
unsigned int mNbConnectTriesTotal;
|
||||
unsigned int mNbConnectTries;
|
||||
QTimer *mReconnectTimer;
|
||||
};
|
||||
|
@ -56,7 +56,6 @@ int main(int argc, char **argv)
|
||||
app.setMainWidget(sfl);
|
||||
#endif
|
||||
|
||||
app.launch();
|
||||
PhoneLineManager::instance().connect();
|
||||
//splash->finish(sfl);
|
||||
//sfl->show();
|
||||
|
Reference in New Issue
Block a user