Added help file support in client.
git-svn-id: http://voip.null.ro/svn/yate@794 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
aff408a8d7
commit
43b5a7d750
|
@ -1327,7 +1327,10 @@ bool GTKWindow::setText(GtkWidget* wid, const String& text)
|
|||
{
|
||||
XDebug(GTKDriver::self(),DebugAll,"GTKWindow::setText(%p,'%s')",wid,text.safe());
|
||||
if (GTK_IS_LABEL(wid)) {
|
||||
gtk_label_set_text(GTK_LABEL(wid),text.safe());
|
||||
if (text.startsWith("<markup>"))
|
||||
gtk_label_set_markup(GTK_LABEL(wid),text.safe());
|
||||
else
|
||||
gtk_label_set_text(GTK_LABEL(wid),text.safe());
|
||||
return true;
|
||||
}
|
||||
if (GTK_IS_BUTTON(wid)) {
|
||||
|
|
|
@ -542,6 +542,9 @@ void Client::initClient()
|
|||
m_autoAnswer = Engine::config().getBoolValue("client","autoanswer",tmp);
|
||||
setCheck("multilines",m_multiLines);
|
||||
setCheck("autoanswer",m_autoAnswer);
|
||||
Window* help = getWindow("help");
|
||||
if (help)
|
||||
action(help,"help_home");
|
||||
}
|
||||
|
||||
void Client::moveRelated(const Window* wnd, int dx, int dy)
|
||||
|
@ -1316,6 +1319,48 @@ bool Client::action(Window* wnd, const String& name)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
// help window actions
|
||||
else if (wnd && name.startsWith("help_")) {
|
||||
bool show = false;
|
||||
int page = wnd->context().toInteger();
|
||||
if (name == "help_home")
|
||||
page = 0;
|
||||
else if (name == "help_prev")
|
||||
page--;
|
||||
else if (name == "help_next")
|
||||
page++;
|
||||
else if (name.startsWith("help_page:"))
|
||||
page = name.substr(10).toInteger(page);
|
||||
else if (name.startsWith("help_show:")) {
|
||||
page = name.substr(10).toInteger(page);
|
||||
show = true;
|
||||
}
|
||||
if (page < 0)
|
||||
page = 0;
|
||||
String helpFile = Engine::config().getValue("client","helpbase");
|
||||
if (helpFile.null())
|
||||
helpFile << Engine::modulePath() << Engine::pathSeparator() << "help";
|
||||
if (!helpFile.endsWith(Engine::pathSeparator()))
|
||||
helpFile << Engine::pathSeparator();
|
||||
helpFile << page << ".yhlp";
|
||||
File f;
|
||||
f.openPath(helpFile);
|
||||
unsigned int len = f.length();
|
||||
if (len) {
|
||||
String helpText(' ',len);
|
||||
int rd = f.readData(const_cast<char*>(helpText.c_str()),len);
|
||||
if (rd == (int)len) {
|
||||
setText("help_text",helpText,wnd);
|
||||
wnd->context(page);
|
||||
if (show)
|
||||
wnd->show();
|
||||
}
|
||||
else
|
||||
Debug(ClientDriver::self(),DebugWarn,"Read only %d out of %u bytes in file %s",
|
||||
rd,len,helpFile.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// unknown/unhandled - generate a message for them
|
||||
Message* m = new Message("ui.event");
|
||||
|
|
|
@ -483,6 +483,69 @@ bool File::setBlocking(bool block)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool File::openPath(const char* name, bool canWrite, bool canRead, bool create, bool append)
|
||||
{
|
||||
if (!terminate())
|
||||
return false;
|
||||
if (null(name) || !(canWrite || canRead))
|
||||
return false;
|
||||
#ifdef _WINDOWS
|
||||
DWORD access = 0;
|
||||
if (canWrite)
|
||||
access |= GENERIC_WRITE;
|
||||
if (canRead)
|
||||
access |= GENERIC_READ;
|
||||
HANDLE h = CreateFile(name,access,0,NULL,create ? OPEN_ALWAYS : OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (h == invalidHandle()) {
|
||||
copyError();
|
||||
return false;
|
||||
}
|
||||
if (append)
|
||||
SetFilePointer(h,0,NULL,FILE_END);
|
||||
#else
|
||||
int flags = 0;
|
||||
if (canWrite)
|
||||
flags = canRead ? O_RDWR : O_WRONLY;
|
||||
else if (canRead)
|
||||
flags = O_RDONLY;
|
||||
if (create)
|
||||
flags |= O_CREAT;
|
||||
if (append)
|
||||
flags |= O_APPEND;
|
||||
HANDLE h = ::open(name,flags,S_IRWXU);
|
||||
if (h == invalidHandle()) {
|
||||
copyError();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
attach(h);
|
||||
clearError();
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int File::length()
|
||||
{
|
||||
if (!valid())
|
||||
return 0;
|
||||
#ifdef _WINDOWS
|
||||
DWORD sz = GetFileSize(m_handle,NULL);
|
||||
if (sz == (DWORD)-1) {
|
||||
copyError();
|
||||
return 0;
|
||||
}
|
||||
return sz;
|
||||
#else
|
||||
off_t pos = ::lseek(m_handle,0,SEEK_CUR);
|
||||
if (pos == (off_t)-1) {
|
||||
copyError();
|
||||
return 0;
|
||||
}
|
||||
off_t len = ::lseek(m_handle,0,SEEK_END);
|
||||
::lseek(m_handle,pos,SEEK_SET);
|
||||
return (len == (off_t)-1) ? 0 : len;
|
||||
#endif
|
||||
}
|
||||
|
||||
int File::writeData(const void* buffer, int length)
|
||||
{
|
||||
if (!buffer)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<markup><big><b>Yate Help Contents</b></big>
|
||||
|
||||
Yate is a next-generation telephony engine;
|
||||
while currently focused on Voice over Internet
|
||||
Protocol (VoIP) and PSTN, its power lies in
|
||||
its ability to be easily extended.
|
||||
Voice, video, data and instant messaging can
|
||||
all be unified under Yate's flexible routing
|
||||
engine, maximizing communications efficiency
|
||||
and minimizing infrastructure costs for
|
||||
businesses.
|
||||
</markup><!-- pango -->
|
|
@ -0,0 +1,4 @@
|
|||
<markup><big><b>Yate Help Page 1</b></big>
|
||||
|
||||
Page 1 text here
|
||||
</markup><!-- pango -->
|
|
@ -432,10 +432,13 @@ title=Yate Help
|
|||
master=yes
|
||||
visible=no
|
||||
layout=vbox
|
||||
label=2,,,,help_text,<b>Some</b> text here
|
||||
property:int:xpad=4
|
||||
property:int:ypad=2
|
||||
property:bool:use-markup=yes
|
||||
scroll=2,,150,100,>
|
||||
property:int:border-width=2
|
||||
label=2,,,,help_text,<b>Some</b> text here
|
||||
property:int:xpad=4
|
||||
property:int:ypad=2
|
||||
property:bool:use-markup=yes
|
||||
leave=<
|
||||
hbox=>
|
||||
property:int:border-width=2
|
||||
button=1,,75,30,help_prev,Prev
|
||||
|
|
|
@ -109,6 +109,7 @@ Source: "..\modules\skin\default\gtk2client.??"; DestDir: "{app}\modules\skin\de
|
|||
Source: "..\modules\skin\default\*.png"; DestDir: "{app}\modules\skin\default"; Components: client
|
||||
Source: "..\modules\skin\tabbed\gtk2client.??"; DestDir: "{app}\modules\skin\tabbed"; Components: client\skin\tabbed
|
||||
Source: "..\modules\skin\tabbed\*.png"; DestDir: "{app}\modules\skin\tabbed"; Components: client\skin\tabbed
|
||||
Source: "..\modules\help\*.yhlp"; DestDir: "{app}\modules\help"; Components: client
|
||||
|
||||
Source: "..\scripts\*.php"; DestDir: "{app}\scripts"; Components: external\php
|
||||
|
||||
|
|
17
yateclass.h
17
yateclass.h
|
@ -3392,6 +3392,17 @@ public:
|
|||
*/
|
||||
virtual ~File();
|
||||
|
||||
/**
|
||||
* Opens a file from the filesystem pathname
|
||||
* @param name Name of the file according to the operating system's conventions
|
||||
* @param canWrite Open the file for writing
|
||||
* @param canRead Open the file for reading
|
||||
* @param create Create the file if it doesn't exist
|
||||
* @param append Set the write pointer at the end of an existing file
|
||||
* @return True if the file was successfully opened
|
||||
*/
|
||||
virtual bool openPath(const char* name, bool canWrite = false, bool canRead = true, bool create = false, bool append = false);
|
||||
|
||||
/**
|
||||
* Closes the file handle
|
||||
* @return True if the file was (already) closed, false if an error occured
|
||||
|
@ -3442,6 +3453,12 @@ public:
|
|||
*/
|
||||
virtual bool setBlocking(bool block = true);
|
||||
|
||||
/**
|
||||
* Find the length of the file if it has one
|
||||
* @return Length of the file or zero if length is not defined
|
||||
*/
|
||||
virtual unsigned int length();
|
||||
|
||||
/**
|
||||
* Write data to an open file
|
||||
* @param buffer Buffer for data transfer
|
||||
|
|
Loading…
Reference in New Issue