Work in proggress.
git-svn-id: http://yate.null.ro/svn/yate/trunk@754 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
1b24eb60ee
commit
ad23cf9cb2
|
@ -140,6 +140,11 @@ void Window::title(const String& text)
|
||||||
m_title = text;
|
m_title = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::context(const String& text)
|
||||||
|
{
|
||||||
|
m_context = text;
|
||||||
|
}
|
||||||
|
|
||||||
bool Window::related(const Window* wnd) const
|
bool Window::related(const Window* wnd) const
|
||||||
{
|
{
|
||||||
if ((wnd == this) || !wnd || wnd->master())
|
if ((wnd == this) || !wnd || wnd->master())
|
||||||
|
@ -157,6 +162,8 @@ bool Window::setParams(const NamedList& params)
|
||||||
String n(s->name());
|
String n(s->name());
|
||||||
if (n == "title")
|
if (n == "title")
|
||||||
title(*s);
|
title(*s);
|
||||||
|
if (n == "context")
|
||||||
|
context(*s);
|
||||||
else if (n.startSkip("show:",false))
|
else if (n.startSkip("show:",false))
|
||||||
ok = setShow(n,s->toBoolean()) && ok;
|
ok = setShow(n,s->toBoolean()) && ok;
|
||||||
else if (n.startSkip("active:",false))
|
else if (n.startSkip("active:",false))
|
||||||
|
@ -363,7 +370,9 @@ Client* Client::s_client = 0;
|
||||||
int Client::s_changing = 0;
|
int Client::s_changing = 0;
|
||||||
static Configuration s_accounts;
|
static Configuration s_accounts;
|
||||||
static Configuration s_contacts;
|
static Configuration s_contacts;
|
||||||
|
static Configuration s_providers;
|
||||||
|
|
||||||
|
// Parameters that are stored with account
|
||||||
static const char* s_accParams[] = {
|
static const char* s_accParams[] = {
|
||||||
"username",
|
"username",
|
||||||
"password",
|
"password",
|
||||||
|
@ -373,6 +382,14 @@ static const char* s_accParams[] = {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Parameters that are applied from provider template
|
||||||
|
static const char* s_provParams[] = {
|
||||||
|
"server",
|
||||||
|
"domain",
|
||||||
|
"outbound",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Client::Client(const char *name)
|
Client::Client(const char *name)
|
||||||
: Thread(name), m_initialized(false), m_line(0), m_oneThread(true),
|
: Thread(name), m_initialized(false), m_line(0), m_oneThread(true),
|
||||||
|
@ -495,6 +512,17 @@ void Client::initClient()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_providers = Engine::configFile("providers");
|
||||||
|
s_providers.load();
|
||||||
|
n = s_providers.sections();
|
||||||
|
for (i=0; i<n; i++) {
|
||||||
|
NamedList* sect = s_providers.getSection(i);
|
||||||
|
if (sect && sect->getBoolValue("enabled",true)) {
|
||||||
|
if (!hasOption("acc_providers",*sect))
|
||||||
|
addOption("acc_providers",*sect,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool tmp =
|
bool tmp =
|
||||||
getWindow("channels") || hasElement("channels") ||
|
getWindow("channels") || hasElement("channels") ||
|
||||||
getWindow("lines") || hasElement("lines");
|
getWindow("lines") || hasElement("lines");
|
||||||
|
@ -527,6 +555,7 @@ bool Client::openPopup(const String& name, const NamedList* params, const Window
|
||||||
Window* wnd = getWindow(name);
|
Window* wnd = getWindow(name);
|
||||||
if (!wnd)
|
if (!wnd)
|
||||||
return false;
|
return false;
|
||||||
|
wnd->context("");
|
||||||
if (params)
|
if (params)
|
||||||
wnd->setParams(*params);
|
wnd->setParams(*params);
|
||||||
if (parent)
|
if (parent)
|
||||||
|
@ -970,9 +999,8 @@ bool Client::action(Window* wnd, const String& name)
|
||||||
// accounts window actions
|
// accounts window actions
|
||||||
else if (name == "acc_new") {
|
else if (name == "acc_new") {
|
||||||
NamedList params("");
|
NamedList params("");
|
||||||
params.setParam("select:acc_provider","--");
|
params.setParam("select:acc_providers","--");
|
||||||
params.setParam("acc_account","");
|
params.setParam("acc_account","");
|
||||||
params.setParam("acc_account_orig","");
|
|
||||||
params.setParam("acc_username","");
|
params.setParam("acc_username","");
|
||||||
params.setParam("acc_password","");
|
params.setParam("acc_password","");
|
||||||
params.setParam("acc_server","");
|
params.setParam("acc_server","");
|
||||||
|
@ -986,9 +1014,9 @@ bool Client::action(Window* wnd, const String& name)
|
||||||
String acc;
|
String acc;
|
||||||
if (getSelect("accounts",acc,wnd)) {
|
if (getSelect("accounts",acc,wnd)) {
|
||||||
NamedList params("");
|
NamedList params("");
|
||||||
params.setParam("select:acc_provider","--");
|
params.setParam("context",acc);
|
||||||
|
params.setParam("select:acc_providers","--");
|
||||||
params.setParam("acc_account",acc);
|
params.setParam("acc_account",acc);
|
||||||
params.setParam("acc_account_orig",acc);
|
|
||||||
NamedList* sect = s_accounts.getSection(acc);
|
NamedList* sect = s_accounts.getSection(acc);
|
||||||
if (sect) {
|
if (sect) {
|
||||||
params.setParam("select:acc_protocol",sect->getValue("protocol"));
|
params.setParam("select:acc_protocol",sect->getValue("protocol"));
|
||||||
|
@ -1030,11 +1058,10 @@ bool Client::action(Window* wnd, const String& name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if the account name has changed, delete old if so
|
// check if the account name has changed, delete old if so
|
||||||
String oldAcc;
|
if (wnd && wnd->context() && (wnd->context() != newAcc)) {
|
||||||
if (getText("acc_account_orig",oldAcc,wnd) && oldAcc && (oldAcc != newAcc)) {
|
s_accounts.clearSection(wnd->context());
|
||||||
s_accounts.clearSection(oldAcc);
|
|
||||||
Message* m = new Message("user.login");
|
Message* m = new Message("user.login");
|
||||||
m->addParam("account",oldAcc);
|
m->addParam("account",wnd->context());
|
||||||
m->addParam("operation","delete");
|
m->addParam("operation","delete");
|
||||||
Engine::enqueue(m);
|
Engine::enqueue(m);
|
||||||
}
|
}
|
||||||
|
@ -1067,7 +1094,6 @@ bool Client::action(Window* wnd, const String& name)
|
||||||
else if (name == "abk_new") {
|
else if (name == "abk_new") {
|
||||||
NamedList params("");
|
NamedList params("");
|
||||||
params.setParam("abk_contact","");
|
params.setParam("abk_contact","");
|
||||||
params.setParam("abk_contact_orig","");
|
|
||||||
params.setParam("abk_number","");
|
params.setParam("abk_number","");
|
||||||
params.setParam("modal",String::boolText(true));
|
params.setParam("modal",String::boolText(true));
|
||||||
if (openPopup("addrbook",¶ms,wnd))
|
if (openPopup("addrbook",¶ms,wnd))
|
||||||
|
@ -1077,8 +1103,8 @@ bool Client::action(Window* wnd, const String& name)
|
||||||
String cnt;
|
String cnt;
|
||||||
if (getSelect("contacts",cnt,wnd)) {
|
if (getSelect("contacts",cnt,wnd)) {
|
||||||
NamedList params("");
|
NamedList params("");
|
||||||
params.setParam("abk_contact_orig",cnt);
|
|
||||||
params.setParam("abk_contact",cnt);
|
params.setParam("abk_contact",cnt);
|
||||||
|
params.setParam("context",cnt);
|
||||||
params.setParam("modal",String::boolText(true));
|
params.setParam("modal",String::boolText(true));
|
||||||
if (openPopup("addrbook",¶ms,wnd))
|
if (openPopup("addrbook",¶ms,wnd))
|
||||||
return true;
|
return true;
|
||||||
|
@ -1196,13 +1222,23 @@ bool Client::select(Window* wnd, const String& name, const String& item, const S
|
||||||
if (setSelect("account","") || setSelect("account","--"))
|
if (setSelect("account","") || setSelect("account","--"))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (name == "acc_provider") {
|
else if (name == "acc_providers") {
|
||||||
// apply provider template
|
// apply provider template
|
||||||
if (checkDashes(item))
|
if (checkDashes(item))
|
||||||
return true;
|
return true;
|
||||||
// reset selection after we apply it
|
// reset selection after we apply it
|
||||||
if (setSelect(name,"") || setSelect(name,"--"))
|
if (!setSelect(name,""))
|
||||||
return true;
|
setSelect(name,"--");
|
||||||
|
NamedList* sect = s_providers.getSection(item);
|
||||||
|
if (!sect)
|
||||||
|
return false;
|
||||||
|
setSelect("acc_protocol",sect->getValue("protocol"));
|
||||||
|
for (const char** par = s_provParams; *par; par++) {
|
||||||
|
String name;
|
||||||
|
name << "acc_" << *par;
|
||||||
|
setText(name,sect->getValue(*par));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown/unhandled - generate a message for them
|
// unknown/unhandled - generate a message for them
|
||||||
|
|
|
@ -306,7 +306,7 @@ vbox=>
|
||||||
hbox=>
|
hbox=>
|
||||||
vbox=0,2,,,>
|
vbox=0,2,,,>
|
||||||
label=Use provider settings
|
label=Use provider settings
|
||||||
option=,,,,acc_provider,--,FWD
|
option=,,,,acc_providers,--
|
||||||
tooltip=Apply template settings for this provider
|
tooltip=Apply template settings for this provider
|
||||||
label=Account name
|
label=Account name
|
||||||
editor=,,,,acc_account,
|
editor=,,,,acc_account,
|
||||||
|
|
146
yatecbase.h
146
yatecbase.h
|
@ -49,22 +49,129 @@ class YATE_API Window : public GenObject
|
||||||
{
|
{
|
||||||
friend class Client;
|
friend class Client;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor, creates a new windows with an ID
|
||||||
|
* @param id String identifier of the new window
|
||||||
|
*/
|
||||||
Window(const char* id = 0);
|
Window(const char* id = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrive the standard name of this Window, used to search in lists
|
||||||
|
* @return Identifier of this window
|
||||||
|
*/
|
||||||
virtual const String& toString() const;
|
virtual const String& toString() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the window's title (may not be displayed on screen)
|
||||||
|
* @return Title of this window
|
||||||
|
*/
|
||||||
virtual void title(const String& text);
|
virtual void title(const String& text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contextual information previously associated with this window
|
||||||
|
* @return String contextual information
|
||||||
|
*/
|
||||||
|
virtual void context(const String& text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set window parameters or widget contents
|
||||||
|
* @param params List of parameters to set in the window and its widgets
|
||||||
|
* @return True if all parameters could be set
|
||||||
|
*/
|
||||||
virtual bool setParams(const NamedList& params);
|
virtual bool setParams(const NamedList& params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force this window on top of another one which becomes its parent
|
||||||
|
* @param parent Window to force as parent of this one
|
||||||
|
*/
|
||||||
virtual void setOver(const Window* parent) = 0;
|
virtual void setOver(const Window* parent) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this window has an element by name
|
||||||
|
* @param name Name of the element to search for
|
||||||
|
* @return True if one element with the given name exists
|
||||||
|
*/
|
||||||
virtual bool hasElement(const String& name) = 0;
|
virtual bool hasElement(const String& name) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an element as interactive in the window
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param active True to make interactive, false to disallow interaction
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool setActive(const String& name, bool active) = 0;
|
virtual bool setActive(const String& name, bool active) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the visibility of an element in the window
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param visible True to make element visible, false to hide it
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool setShow(const String& name, bool visible) = 0;
|
virtual bool setShow(const String& name, bool visible) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the displayed text of an element in the window
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param text Text value to set in the element
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool setText(const String& name, const String& text) = 0;
|
virtual bool setText(const String& name, const String& text) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the checked or toggled status of an element in the window
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param checked True to make element checked or toggled
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool setCheck(const String& name, bool checked) = 0;
|
virtual bool setCheck(const String& name, bool checked) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the selection of an item in an element in the window
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param item Name of the item that should be selected
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool setSelect(const String& name, const String& item) = 0;
|
virtual bool setSelect(const String& name, const String& item) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag an element as requiring immediate attention
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param urgent True if the element requires immediate attention
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool setUrgent(const String& name, bool urgent) = 0;
|
virtual bool setUrgent(const String& name, bool urgent) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an element has an item by its name
|
||||||
|
* @param name Name of the element to search for
|
||||||
|
* @param item Name of the item that should be searched
|
||||||
|
* @return True if one item with the given name exists in the element
|
||||||
|
*/
|
||||||
virtual bool hasOption(const String& name, const String& item) = 0;
|
virtual bool hasOption(const String& name, const String& item) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an item to an element that supports such an operation (list)
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param item Name of the item to add
|
||||||
|
* @param atStart True to insert item on the first position, false to append
|
||||||
|
* @param text Displayed text to associate with the item (not all lists support it)
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool addOption(const String& name, const String& item, bool atStart = false, const String& text = String::empty()) = 0;
|
virtual bool addOption(const String& name, const String& item, bool atStart = false, const String& text = String::empty()) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an item from an element (list)
|
||||||
|
* @param name Name of the element
|
||||||
|
* @param item Name of the item to remove
|
||||||
|
* @return True if the operation was successfull
|
||||||
|
*/
|
||||||
virtual bool delOption(const String& name, const String& item) = 0;
|
virtual bool delOption(const String& name, const String& item) = 0;
|
||||||
|
|
||||||
virtual bool addTableRow(const String& name, const String& item, const NamedList* data = 0, bool atStart = false);
|
virtual bool addTableRow(const String& name, const String& item, const NamedList* data = 0, bool atStart = false);
|
||||||
virtual bool delTableRow(const String& name, const String& item);
|
virtual bool delTableRow(const String& name, const String& item);
|
||||||
virtual bool setTableRow(const String& name, const String& item, const NamedList* data);
|
virtual bool setTableRow(const String& name, const String& item, const NamedList* data);
|
||||||
|
@ -82,21 +189,60 @@ public:
|
||||||
virtual void moveRel(int dx, int dy) = 0;
|
virtual void moveRel(int dx, int dy) = 0;
|
||||||
virtual bool related(const Window* wnd) const;
|
virtual bool related(const Window* wnd) const;
|
||||||
virtual void menu(int x, int y) = 0;
|
virtual void menu(int x, int y) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrive the standard name of this Window
|
||||||
|
* @return Identifier of this window
|
||||||
|
*/
|
||||||
inline const String& id() const
|
inline const String& id() const
|
||||||
{ return m_id; }
|
{ return m_id; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the window's title (may not be displayed on screen)
|
||||||
|
* @return Title of this window
|
||||||
|
*/
|
||||||
inline const String& title() const
|
inline const String& title() const
|
||||||
{ return m_title; }
|
{ return m_title; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contextual information previously associated with this window
|
||||||
|
* @return String contextual information
|
||||||
|
*/
|
||||||
|
inline const String& context() const
|
||||||
|
{ return m_context; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the visibility status of this window
|
||||||
|
* @return True if window is visible, false if it's hidden
|
||||||
|
*/
|
||||||
inline bool visible() const
|
inline bool visible() const
|
||||||
{ return m_visible; }
|
{ return m_visible; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the visibility status of this window
|
||||||
|
* @param yes True if window should be visible
|
||||||
|
*/
|
||||||
inline void visible(bool yes)
|
inline void visible(bool yes)
|
||||||
{ if (yes) show(); else hide(); }
|
{ if (yes) show(); else hide(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this window is a master (topmost) window
|
||||||
|
* @return True if this window is topmost
|
||||||
|
*/
|
||||||
inline bool master() const
|
inline bool master() const
|
||||||
{ return m_master; }
|
{ return m_master; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this window is a popup window
|
||||||
|
* @return True if this window is initially hidden
|
||||||
|
*/
|
||||||
inline bool popup() const
|
inline bool popup() const
|
||||||
{ return m_popup; }
|
{ return m_popup; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
String m_id;
|
String m_id;
|
||||||
String m_title;
|
String m_title;
|
||||||
|
String m_context;
|
||||||
bool m_visible;
|
bool m_visible;
|
||||||
bool m_master;
|
bool m_master;
|
||||||
bool m_popup;
|
bool m_popup;
|
||||||
|
|
Loading…
Reference in New Issue