mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-31 01:47:16 +01:00
Migrated the IRC module to C++ exceptions as well.
Also enabled the latest C++ revision in the project. Various other fixes and improvements.
This commit is contained in:
parent
8333cc83ce
commit
7f0480c966
@ -16,6 +16,7 @@
|
|||||||
<Add option="-m32" />
|
<Add option="-m32" />
|
||||||
<Add option="-g" />
|
<Add option="-g" />
|
||||||
<Add option="-D_DEBUG" />
|
<Add option="-D_DEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add directory="../config/mingw32" />
|
<Add directory="../config/mingw32" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
@ -37,6 +38,7 @@
|
|||||||
<Add option="-O3" />
|
<Add option="-O3" />
|
||||||
<Add option="-m32" />
|
<Add option="-m32" />
|
||||||
<Add option="-DNDEBUG" />
|
<Add option="-DNDEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add directory="../config/mingw32" />
|
<Add directory="../config/mingw32" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
@ -59,6 +61,7 @@
|
|||||||
<Add option="-m64" />
|
<Add option="-m64" />
|
||||||
<Add option="-g" />
|
<Add option="-g" />
|
||||||
<Add option="-D_DEBUG" />
|
<Add option="-D_DEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add option="-D_SQ64" />
|
<Add option="-D_SQ64" />
|
||||||
<Add directory="../config/mingw64" />
|
<Add directory="../config/mingw64" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
@ -81,6 +84,7 @@
|
|||||||
<Add option="-O3" />
|
<Add option="-O3" />
|
||||||
<Add option="-m64" />
|
<Add option="-m64" />
|
||||||
<Add option="-DNDEBUG" />
|
<Add option="-DNDEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add option="-D_SQ64" />
|
<Add option="-D_SQ64" />
|
||||||
<Add directory="../config/mingw64" />
|
<Add directory="../config/mingw64" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
@ -183,6 +187,7 @@
|
|||||||
<Add option="-static-libstdc++" />
|
<Add option="-static-libstdc++" />
|
||||||
<Add option="-enable-static" />
|
<Add option="-enable-static" />
|
||||||
<Add option="-D_DEBUG" />
|
<Add option="-D_DEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add directory="../config/mingw32" />
|
<Add directory="../config/mingw32" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
@ -208,6 +213,7 @@
|
|||||||
<Add option="-static-libstdc++" />
|
<Add option="-static-libstdc++" />
|
||||||
<Add option="-enable-static" />
|
<Add option="-enable-static" />
|
||||||
<Add option="-DNDEBUG" />
|
<Add option="-DNDEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add directory="../config/mingw32" />
|
<Add directory="../config/mingw32" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
@ -234,6 +240,7 @@
|
|||||||
<Add option="-static-libstdc++" />
|
<Add option="-static-libstdc++" />
|
||||||
<Add option="-enable-static" />
|
<Add option="-enable-static" />
|
||||||
<Add option="-D_DEBUG" />
|
<Add option="-D_DEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add option="-D_SQ64" />
|
<Add option="-D_SQ64" />
|
||||||
<Add directory="../config/mingw64" />
|
<Add directory="../config/mingw64" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
@ -260,6 +267,7 @@
|
|||||||
<Add option="-static-libstdc++" />
|
<Add option="-static-libstdc++" />
|
||||||
<Add option="-enable-static" />
|
<Add option="-enable-static" />
|
||||||
<Add option="-DNDEBUG" />
|
<Add option="-DNDEBUG" />
|
||||||
|
<Add option="-DWIN32" />
|
||||||
<Add option="-D_SQ64" />
|
<Add option="-D_SQ64" />
|
||||||
<Add directory="../config/mingw64" />
|
<Add directory="../config/mingw64" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
@ -370,7 +378,10 @@
|
|||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-Wextra" />
|
<Add option="-Wextra" />
|
||||||
<Add option="-Wall" />
|
<Add option="-Wall" />
|
||||||
|
<Add option="-std=c++14" />
|
||||||
<Add option="-DSQMOD_PLUGIN_API" />
|
<Add option="-DSQMOD_PLUGIN_API" />
|
||||||
|
<Add option="-DSCRAT_USE_EXCEPTIONS" />
|
||||||
|
<Add option="-DSCRAT_USE_CXX11_OPTIMIZATIONS" />
|
||||||
<Add directory="../external/LibIRC" />
|
<Add directory="../external/LibIRC" />
|
||||||
<Add directory="../shared" />
|
<Add directory="../shared" />
|
||||||
<Add directory="../include" />
|
<Add directory="../include" />
|
||||||
|
@ -2,15 +2,76 @@
|
|||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
#include "Module.hpp"
|
#include "Module.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqrat.h>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <libircclient.h>
|
#include <libircclient.h>
|
||||||
#include <libirc_rfcnumeric.h>
|
#include <libirc_rfcnumeric.h>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQChar g_Buffer[512];
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
static SQChar g_Buffer[4096]; // Common buffer to reduce memory allocations.
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SStr GetTempBuff()
|
||||||
|
{
|
||||||
|
return g_Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Uint32 GetTempBuffSize()
|
||||||
|
{
|
||||||
|
return sizeof(g_Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void SqThrowF(CSStr str, ...)
|
||||||
|
{
|
||||||
|
// Initialize the argument list
|
||||||
|
va_list args;
|
||||||
|
va_start (args, str);
|
||||||
|
// Write the requested contents
|
||||||
|
if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
||||||
|
strcpy(g_Buffer, "Unknown error has occurred");
|
||||||
|
// Release the argument list
|
||||||
|
va_end(args);
|
||||||
|
// Throw the exception with the resulted message
|
||||||
|
throw Sqrat::Exception(g_Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
CSStr FmtStr(CSStr str, ...)
|
||||||
|
{
|
||||||
|
// Initialize the argument list
|
||||||
|
va_list args;
|
||||||
|
va_start (args, str);
|
||||||
|
// Write the requested contents
|
||||||
|
if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
||||||
|
g_Buffer[0] = 0; /* make sure the string is terminated */
|
||||||
|
// Release the argument list
|
||||||
|
va_end(args);
|
||||||
|
// Return the data from the buffer
|
||||||
|
return g_Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
StackGuard::StackGuard(HSQUIRRELVM vm)
|
||||||
|
: m_Top(sq_gettop(vm)), m_VM(vm)
|
||||||
|
{
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
StackGuard::~StackGuard()
|
||||||
|
{
|
||||||
|
sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
CSStr GetNick(CSStr origin)
|
CSStr GetNick(CSStr origin)
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "ModBase.hpp"
|
#include "ModBase.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
extern "C" {
|
||||||
|
struct SQVM;
|
||||||
|
typedef struct SQVM* HSQUIRRELVM;
|
||||||
|
} /*extern "C"*/
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
@ -25,6 +31,70 @@ namespace SqMod {
|
|||||||
*/
|
*/
|
||||||
class Session;
|
class Session;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the temporary buffer.
|
||||||
|
*/
|
||||||
|
SStr GetTempBuff();
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the size of the temporary buffer.
|
||||||
|
*/
|
||||||
|
Uint32 GetTempBuffSize();
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Throw a formatted exception.
|
||||||
|
*/
|
||||||
|
void SqThrowF(CSStr str, ...);
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Generate a formatted string.
|
||||||
|
*/
|
||||||
|
CSStr FmtStr(CSStr str, ...);
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Implements RAII to restore the VM stack to it's initial size on function exit.
|
||||||
|
*/
|
||||||
|
struct StackGuard
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Base constructor.
|
||||||
|
*/
|
||||||
|
StackGuard(HSQUIRRELVM vm);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~StackGuard();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
StackGuard(const StackGuard &);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
StackGuard(StackGuard &&);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator.
|
||||||
|
*/
|
||||||
|
StackGuard & operator = (const StackGuard &);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
StackGuard & operator = (StackGuard &&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Int32 m_Top; /* The top of the stack when this instance was created. */
|
||||||
|
HSQUIRRELVM m_VM; /* The VM where the stack should be restored. */
|
||||||
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Extract the name from the specified origin.
|
* Extract the name from the specified origin.
|
||||||
*/
|
*/
|
||||||
|
@ -186,7 +186,7 @@ void RegisterAPI(HSQUIRRELVM vm)
|
|||||||
.Ctor()
|
.Ctor()
|
||||||
/* Core Metamethods */
|
/* Core Metamethods */
|
||||||
.Func(_SC("_cmp"), &Session::Cmp)
|
.Func(_SC("_cmp"), &Session::Cmp)
|
||||||
.Func(_SC("_typename"), &Session::Typename)
|
.SquirrelFunc(_SC("_typename"), &Session::Typename)
|
||||||
.Func(_SC("_tostring"), &Session::ToString)
|
.Func(_SC("_tostring"), &Session::ToString)
|
||||||
/* Properties */
|
/* Properties */
|
||||||
.Prop(_SC("Valid"), &Session::IsValid)
|
.Prop(_SC("Valid"), &Session::IsValid)
|
||||||
|
@ -24,6 +24,14 @@ Session* Session::s_Session = NULL;
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Session::Sessions Session::s_Sessions;
|
Session::Sessions Session::s_Sessions;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQInteger Session::Typename(HSQUIRRELVM vm)
|
||||||
|
{
|
||||||
|
static SQChar name[] = _SC("SqIrcSession");
|
||||||
|
sq_pushstring(vm, name, sizeof(name));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Session::Process()
|
void Session::Process()
|
||||||
{
|
{
|
||||||
@ -199,43 +207,41 @@ void Session::Destroy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Session::Validate() const
|
void Session::Validate() const
|
||||||
{
|
|
||||||
if (m_Session)
|
|
||||||
return true;
|
|
||||||
// Invalid session instance
|
|
||||||
_SqMod->SqThrow("Invalid IRC session (%s)", m_Tag.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
bool Session::ConnectedThrow() const
|
|
||||||
{
|
{
|
||||||
|
// Do we have a valid session handle?
|
||||||
if (!m_Session)
|
if (!m_Session)
|
||||||
_SqMod->SqThrow("Invalid IRC session (%s)", m_Tag.c_str());
|
SqThrowF("Invalid IRC session");
|
||||||
else if (!irc_is_connected(m_Session))
|
|
||||||
_SqMod->SqThrow("Session is not connected (%s)", m_Tag.c_str());
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Session::NotConnected() const
|
void Session::ValidateConnection() const
|
||||||
{
|
{
|
||||||
if (!m_Session || !irc_is_connected(m_Session) || !m_Reconnect)
|
// Do we have a valid session handle?
|
||||||
return true;
|
if (!m_Session)
|
||||||
_SqMod->SqThrow("Already connected or trying connect to IRC server (%s)", m_Tag.c_str());
|
SqThrowF("Invalid IRC session");
|
||||||
return !m_Session;
|
// Is the session connected?
|
||||||
|
else if (!irc_is_connected(m_Session))
|
||||||
|
SqThrowF("Session is not connected");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Session::IsNotConnected() const
|
||||||
|
{
|
||||||
|
// Do we have a session that is not connected or trying to connect?
|
||||||
|
if (m_Session && (irc_is_connected(m_Session) || m_Reconnect))
|
||||||
|
SqThrowF("Already connected or trying connect to IRC server");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Session::ValidateEventSession(Session * ptr)
|
bool Session::ValidateEventSession(Session * ptr)
|
||||||
{
|
{
|
||||||
|
// Is the session instance valid?
|
||||||
if (ptr)
|
if (ptr)
|
||||||
return true;
|
return true;
|
||||||
// Invalid session instance
|
// We can't throw an error here so we simply log it
|
||||||
_SqMod->LogErr("Cannot forward IRC event without a session container");
|
_SqMod->LogErr("Cannot forward IRC event without a session container");
|
||||||
|
// Invalid session instance
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,9 +266,10 @@ Session::Session()
|
|||||||
{
|
{
|
||||||
if (!m_Session)
|
if (!m_Session)
|
||||||
{
|
{
|
||||||
_SqMod->SqThrow("Unable to create an IRC session");
|
|
||||||
// Explicitly make sure no further calls can be made to this session
|
// Explicitly make sure no further calls can be made to this session
|
||||||
m_Session = NULL;
|
m_Session = NULL;
|
||||||
|
// Now it's safe to throw the error
|
||||||
|
SqThrowF("Unable to create an IRC session");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -270,26 +277,18 @@ Session::Session()
|
|||||||
irc_set_ctx(m_Session, this);
|
irc_set_ctx(m_Session, this);
|
||||||
// Is this the only session instance?
|
// Is this the only session instance?
|
||||||
if (!s_Session && s_Sessions.empty())
|
if (!s_Session && s_Sessions.empty())
|
||||||
{
|
|
||||||
s_Session = this;
|
s_Session = this;
|
||||||
}
|
// Is this the second session instance?
|
||||||
else if (s_Sessions.empty())
|
else if (s_Sessions.empty())
|
||||||
{
|
{
|
||||||
s_Sessions.push_back(s_Session);
|
s_Sessions.push_back(s_Session);
|
||||||
s_Session = NULL;
|
s_Session = NULL;
|
||||||
s_Sessions.push_back(this);
|
s_Sessions.push_back(this);
|
||||||
}
|
}
|
||||||
|
// This is part of multiple session instances
|
||||||
else
|
else
|
||||||
{
|
|
||||||
s_Sessions.push_back(this);
|
s_Sessions.push_back(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Because Sqrat is majorly stupid and clears the error message
|
|
||||||
// then does an assert on debug builds thinking the type wasn't registered
|
|
||||||
// or throws a generic "unknown error" message on release builds
|
|
||||||
// we have to use this approach
|
|
||||||
if (Sqrat::Error::Occurred(_SqVM))
|
|
||||||
_SqMod->LogErr("%s", Sqrat::Error::Message(_SqVM).c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -309,260 +308,233 @@ Session::~Session()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Session::SetNick(CSStr nick)
|
void Session::SetNick(CSStr nick)
|
||||||
{
|
{
|
||||||
|
// Validate the handle
|
||||||
|
Validate();
|
||||||
|
// Validate the specified nick name
|
||||||
if (!nick || strlen(nick) <= 0)
|
if (!nick || strlen(nick) <= 0)
|
||||||
_SqMod->SqThrow("Invalid IRC nickname");
|
SqThrowF("Invalid IRC nickname");
|
||||||
|
// Do we have to issue a nickname command?
|
||||||
else if (Connected())
|
else if (Connected())
|
||||||
irc_cmd_nick(m_Session, nick);
|
irc_cmd_nick(m_Session, nick);
|
||||||
else if (Validate())
|
// Simply save the specified nickname
|
||||||
|
else
|
||||||
m_Nick.assign(nick);
|
m_Nick.assign(nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Session::SetPort(Uint32 num)
|
void Session::SetPort(Uint32 num)
|
||||||
{
|
{
|
||||||
|
// The port cannot be changed once connected!
|
||||||
|
IsNotConnected();
|
||||||
|
// Validate the specified port number
|
||||||
if (num > 0xFFFF)
|
if (num > 0xFFFF)
|
||||||
_SqMod->SqThrow("Port number is out of range: %u > %u", num, 0xFFFF);
|
SqThrowF("Port number is out of range: %u > %u", num, 0xFFFF);
|
||||||
else if (Validate() && NotConnected())
|
// Assign the specified port number
|
||||||
m_Port = num;
|
m_Port = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 Session::CmdNick(CSStr nick)
|
Int32 Session::CmdNick(CSStr nick)
|
||||||
{
|
{
|
||||||
|
// Make sure the session is connected
|
||||||
|
ValidateConnection();
|
||||||
|
// Validate the specified nick name
|
||||||
if (!nick || strlen(nick) <= 0)
|
if (!nick || strlen(nick) <= 0)
|
||||||
_SqMod->SqThrow("Invalid IRC nickname");
|
SqThrowF("Invalid IRC nickname");
|
||||||
else if (ConnectedThrow())
|
// Issue the command and return the result
|
||||||
return irc_cmd_nick(m_Session, nick);
|
return irc_cmd_nick(m_Session, nick);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Session::GetNextTry() const
|
Object Session::GetNextTry() const
|
||||||
{
|
{
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const Int32 top = sq_gettop(_SqVM);
|
const StackGuard sg(_SqVM);
|
||||||
// Attempt to push a time-stamp instance on the stack
|
// Attempt to push a time-stamp instance on the stack
|
||||||
_SqMod->PushTimestamp(_SqVM, m_NextTry);
|
_SqMod->PushTimestamp(_SqVM, m_NextTry);
|
||||||
// Obtain the object from the stack
|
// Obtain the object from the stack and return it
|
||||||
Var< Object > inst(_SqVM, -1);
|
return Var< Object >(_SqVM, -1).value;
|
||||||
// Remove an pushed values (if any) to restore the stack
|
|
||||||
sq_pop(_SqVM, sq_gettop(_SqVM) - top);
|
|
||||||
// Return the timestamp instance
|
|
||||||
return inst.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Session::SetNextTry(Object & tm)
|
void Session::SetNextTry(Object & tm)
|
||||||
{
|
{
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const Int32 top = sq_gettop(_SqVM);
|
const StackGuard sg(_SqVM);
|
||||||
// Push the specified object onto the stack
|
// Push the specified object onto the stack
|
||||||
Var< Object >::push(_SqVM, tm);
|
Var< Object >::push(_SqVM, tm);
|
||||||
// The resulted times-tamp value
|
// The resulted times-tamp value
|
||||||
Int64 microseconds = 0;
|
Int64 microseconds = 0;
|
||||||
// Attempt to get the numeric value inside the specified object
|
// Attempt to get the numeric value inside the specified object
|
||||||
if (SQ_FAILED(_SqMod->GetTimestamp(_SqVM, -1, µseconds)))
|
if (SQ_FAILED(_SqMod->GetTimestamp(_SqVM, -1, µseconds)))
|
||||||
_SqMod->SqThrow("Invalid time-stamp specified");
|
SqThrowF("Invalid time-stamp specified");
|
||||||
else
|
// Assign the specified timestamp value
|
||||||
m_NextTry = microseconds;
|
m_NextTry = microseconds;
|
||||||
// Remove an pushed values (if any) to restore the stack
|
|
||||||
sq_pop(_SqVM, sq_gettop(_SqVM) - top);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Session::GetSessionTime() const
|
Object Session::GetSessionTime() const
|
||||||
{
|
{
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const Int32 top = sq_gettop(_SqVM);
|
const StackGuard sg(_SqVM);
|
||||||
// Attempt to push a time-stamp instance on the stack
|
// Attempt to push a time-stamp instance on the stack
|
||||||
if (m_SessionTime)
|
if (m_SessionTime)
|
||||||
_SqMod->PushTimestamp(_SqVM, _SqMod->GetEpochTimeMicro() - m_SessionTime);
|
_SqMod->PushTimestamp(_SqVM, _SqMod->GetEpochTimeMicro() - m_SessionTime);
|
||||||
|
// This session was not connected yet
|
||||||
else
|
else
|
||||||
_SqMod->PushTimestamp(_SqVM, 0);
|
_SqMod->PushTimestamp(_SqVM, 0);
|
||||||
// Obtain the object from the stack
|
// Obtain the object from the stack and return it
|
||||||
Var< Object > inst(_SqVM, -1);
|
return Var< Object >(_SqVM, -1).value;
|
||||||
// Remove an pushed values (if any) to restore the stack
|
|
||||||
sq_pop(_SqVM, sq_gettop(_SqVM) - top);
|
|
||||||
// Return the timestamp instance
|
|
||||||
return inst.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 Session::Connect()
|
Int32 Session::Connect()
|
||||||
{
|
{
|
||||||
// Are we even allowed to try to connect?
|
// Validate the handle
|
||||||
if (!Validate() || !NotConnected())
|
Validate();
|
||||||
return -1; /* No point in going forward */
|
// Make sure we are allowed to connect
|
||||||
// Did we already try to connect?
|
IsNotConnected();
|
||||||
else if (m_Reconnect)
|
|
||||||
_SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
|
|
||||||
// Validate the specified server
|
// Validate the specified server
|
||||||
else if (!m_Server.empty())
|
if (!m_Server.empty())
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a server");
|
SqThrowF("Attempting to connect IRC without specifying a server");
|
||||||
// Validate the specified nickname
|
// Validate the specified nickname
|
||||||
else if (!m_Nick.empty())
|
else if (!m_Nick.empty())
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
|
SqThrowF("Attempting to connect IRC without specifying a nickname");
|
||||||
else
|
// Enable the reconnection system
|
||||||
{
|
m_Reconnect = true;
|
||||||
// Enable the reconnection system
|
// Reset the number of tries
|
||||||
m_Reconnect = true;
|
m_LeftTries = m_Tries;
|
||||||
// Reset the number of tries
|
// Set the time-point for the next try
|
||||||
m_LeftTries = m_Tries;
|
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
||||||
// Set the time-point for the next try
|
// This is not an IPv6 connection
|
||||||
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
m_IPv6 = false;
|
||||||
// This is not an IPv6 connection
|
// Attempt to connect the session and return the result
|
||||||
m_IPv6 = false;
|
return irc_connect(m_Session, m_Server.c_str(), m_Port,
|
||||||
// Attempt to connect the session and return the result
|
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
||||||
return irc_connect(m_Session, m_Server.c_str(), m_Port,
|
m_Nick.c_str(),
|
||||||
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
m_User.empty() ? NULL : m_User.c_str(),
|
||||||
m_Nick.c_str(),
|
m_Name.empty() ? NULL : m_Name.c_str()
|
||||||
m_User.empty() ? NULL : m_User.c_str(),
|
);
|
||||||
m_Name.empty() ? NULL : m_Name.c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Connection denied before even attempted
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 Session::Connect(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSStr user, CSStr name)
|
Int32 Session::Connect(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSStr user, CSStr name)
|
||||||
{
|
{
|
||||||
// Are we even allowed to try to connect?
|
// Validate the handle
|
||||||
if (!Validate() || !NotConnected())
|
Validate();
|
||||||
return -1; /* No point in going forward */
|
// Make sure we are allowed to connect
|
||||||
// Did we already try to connect?
|
IsNotConnected();
|
||||||
else if (m_Reconnect)
|
|
||||||
_SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
|
|
||||||
// Validate the specified port
|
// Validate the specified port
|
||||||
else if (port > 0xFFFF)
|
if (port > 0xFFFF)
|
||||||
_SqMod->SqThrow("Port number is out of range: %u > %u", port, 0xFFFF);
|
SqThrowF("Port number is out of range: %u > %u", port, 0xFFFF);
|
||||||
// Validate the specified server
|
// Validate the specified server
|
||||||
else if (!server || strlen(server) <= 0)
|
else if (!server || strlen(server) <= 0)
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a server");
|
SqThrowF("Attempting to connect IRC without specifying a server");
|
||||||
// Validate the specified nickname
|
// Validate the specified nickname
|
||||||
else if (!nick || strlen(nick) <= 0)
|
else if (!nick || strlen(nick) <= 0)
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
|
SqThrowF("Attempting to connect IRC without specifying a nickname");
|
||||||
else
|
// Save the specified port
|
||||||
{
|
m_Port = port;
|
||||||
// Save the specified port
|
// Save the specified server
|
||||||
m_Port = port;
|
m_Server.assign(server);
|
||||||
// Save the specified server
|
// Save the specified nickname
|
||||||
m_Server.assign(server);
|
m_Nick.assign(nick);
|
||||||
// Save the specified nickname
|
// Save the specified password
|
||||||
m_Nick.assign(nick);
|
m_Passwd.assign(passwd ? passwd : _SC(""));
|
||||||
// Save the specified password
|
// Save the specified user
|
||||||
m_Passwd.assign(!passwd ? _SC("") : passwd);
|
m_User.assign(user ? user : _SC(""));
|
||||||
// Save the specified user
|
// Save the specified name
|
||||||
m_User.assign(!user ? _SC("") : user);
|
m_Name.assign(name ? name : _SC(""));
|
||||||
// Save the specified name
|
// Enable the reconnection system
|
||||||
m_Name.assign(!name ? _SC("") : name);
|
m_Reconnect = true;
|
||||||
// Enable the reconnection system
|
// Reset the number of tries
|
||||||
m_Reconnect = true;
|
m_LeftTries = m_Tries;
|
||||||
// Reset the number of tries
|
// Set the time-point for the next connection try
|
||||||
m_LeftTries = m_Tries;
|
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
||||||
// Set the time-point for the next connection try
|
// This is not an IPv6 connection
|
||||||
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
m_IPv6 = false;
|
||||||
// This is not an IPv6 connection
|
// Attempt to connect the session and return the result
|
||||||
m_IPv6 = false;
|
return irc_connect(m_Session, m_Server.c_str(), m_Port,
|
||||||
// Attempt to connect the session and return the result
|
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
||||||
return irc_connect(m_Session, m_Server.c_str(), m_Port,
|
m_Nick.c_str(),
|
||||||
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
m_User.empty() ? NULL : m_User.c_str(),
|
||||||
m_Nick.c_str(),
|
m_Name.empty() ? NULL : m_Name.c_str()
|
||||||
m_User.empty() ? NULL : m_User.c_str(),
|
);
|
||||||
m_Name.empty() ? NULL : m_Name.c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Connection denied before even attempted
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 Session::Connect6()
|
Int32 Session::Connect6()
|
||||||
{
|
{
|
||||||
// Are we even allowed to try to connect?
|
// Validate the handle
|
||||||
if (!Validate() || !NotConnected())
|
Validate();
|
||||||
return -1; /* No point in going forward */
|
// Make sure we are allowed to connect
|
||||||
// Did we already try to connect?
|
IsNotConnected();
|
||||||
else if (m_Reconnect)
|
|
||||||
_SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
|
|
||||||
// Validate the specified server
|
// Validate the specified server
|
||||||
else if (!m_Server.empty())
|
if (!m_Server.empty())
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a server");
|
SqThrowF("Attempting to connect IRC without specifying a server");
|
||||||
// Validate the specified nickname
|
// Validate the specified nickname
|
||||||
else if (!m_Nick.empty())
|
else if (!m_Nick.empty())
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
|
SqThrowF("Attempting to connect IRC without specifying a nickname");
|
||||||
else
|
// Enable the reconnection system
|
||||||
{
|
m_Reconnect = true;
|
||||||
// Enable the reconnection system
|
// Reset the number of tries
|
||||||
m_Reconnect = true;
|
m_LeftTries = m_Tries;
|
||||||
// Reset the number of tries
|
// Set the time-point for the next try
|
||||||
m_LeftTries = m_Tries;
|
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
||||||
// Set the time-point for the next try
|
// This is an IPv6 connection
|
||||||
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
m_IPv6 = true;
|
||||||
// This is an IPv6 connection
|
// Attempt to connect the session and return the result
|
||||||
m_IPv6 = true;
|
return irc_connect6(m_Session, m_Server.c_str(), m_Port,
|
||||||
// Attempt to connect the session and return the result
|
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
||||||
return irc_connect6(m_Session, m_Server.c_str(), m_Port,
|
m_Nick.c_str(),
|
||||||
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
m_User.empty() ? NULL : m_User.c_str(),
|
||||||
m_Nick.c_str(),
|
m_Name.empty() ? NULL : m_Name.c_str()
|
||||||
m_User.empty() ? NULL : m_User.c_str(),
|
);
|
||||||
m_Name.empty() ? NULL : m_Name.c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Connection denied before even attempted
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 Session::Connect6(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSStr user, CSStr name)
|
Int32 Session::Connect6(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSStr user, CSStr name)
|
||||||
{
|
{
|
||||||
// Are we even allowed to try to connect?
|
// Validate the handle
|
||||||
if (!Validate() || !NotConnected())
|
Validate();
|
||||||
return -1; /* No point in going forward */
|
// Make sure we are allowed to connect
|
||||||
// Did we already try to connect?
|
IsNotConnected();
|
||||||
else if (m_Reconnect)
|
|
||||||
_SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
|
|
||||||
// Validate the specified port
|
// Validate the specified port
|
||||||
else if (port > 0xFFFF)
|
if (port > 0xFFFF)
|
||||||
_SqMod->SqThrow("Port number is out of range: %u > %u", port, 0xFFFF);
|
SqThrowF("Port number is out of range: %u > %u", port, 0xFFFF);
|
||||||
// Validate the specified server
|
// Validate the specified server
|
||||||
else if (!server || strlen(server) <= 0)
|
else if (!server || strlen(server) <= 0)
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a server");
|
SqThrowF("Attempting to connect IRC without specifying a server");
|
||||||
// Validate the specified nickname
|
// Validate the specified nickname
|
||||||
else if (!nick || strlen(nick) <= 0)
|
else if (!nick || strlen(nick) <= 0)
|
||||||
_SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
|
SqThrowF("Attempting to connect IRC without specifying a nickname");
|
||||||
else
|
// Save the specified port
|
||||||
{
|
m_Port = port;
|
||||||
// Save the specified port
|
// Save the specified server
|
||||||
m_Port = port;
|
m_Server.assign(server);
|
||||||
// Save the specified server
|
// Save the specified nickname
|
||||||
m_Server.assign(server);
|
m_Nick.assign(nick);
|
||||||
// Save the specified nickname
|
// Save the specified password
|
||||||
m_Nick.assign(nick);
|
m_Passwd.assign(passwd ? passwd : _SC(""));
|
||||||
// Save the specified password
|
// Save the specified user
|
||||||
m_Passwd.assign(!passwd ? _SC("") : passwd);
|
m_User.assign(user ? user : _SC(""));
|
||||||
// Save the specified user
|
// Save the specified name
|
||||||
m_User.assign(!user ? _SC("") : user);
|
m_Name.assign(name ? name : _SC(""));
|
||||||
// Save the specified name
|
// Enable the reconnection system
|
||||||
m_Name.assign(!name ? _SC("") : name);
|
m_Reconnect = true;
|
||||||
// Enable the reconnection system
|
// Reset the number of tries
|
||||||
m_Reconnect = true;
|
m_LeftTries = m_Tries;
|
||||||
// Reset the number of tries
|
// Set the time-point for the next connection try
|
||||||
m_LeftTries = m_Tries;
|
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
||||||
// Set the time-point for the next connection try
|
// This is an IPv6 connection
|
||||||
m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
|
m_IPv6 = true;
|
||||||
// This is an IPv6 connection
|
// Attempt to connect the session and return the result
|
||||||
m_IPv6 = true;
|
return irc_connect6(m_Session, m_Server.c_str(), m_Port,
|
||||||
// Attempt to connect the session and return the result
|
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
||||||
return irc_connect6(m_Session, m_Server.c_str(), m_Port,
|
m_Nick.c_str(),
|
||||||
m_Passwd.empty() ? NULL : m_Passwd.c_str(),
|
m_User.empty() ? NULL : m_User.c_str(),
|
||||||
m_Nick.c_str(),
|
m_Name.empty() ? NULL : m_Name.c_str()
|
||||||
m_User.empty() ? NULL : m_User.c_str(),
|
);
|
||||||
m_Name.empty() ? NULL : m_Name.c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Connection denied before even attempted
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -585,16 +557,12 @@ void Session::ForwardEvent(Session * session, Function & listener, CCStr event,
|
|||||||
{
|
{
|
||||||
// Is there anyone even listening to this event?
|
// Is there anyone even listening to this event?
|
||||||
if (listener.IsNull())
|
if (listener.IsNull())
|
||||||
{
|
|
||||||
return; /* No point in going forward */
|
return; /* No point in going forward */
|
||||||
}
|
|
||||||
// Make sure that the origin can't be a null pointer
|
// Make sure that the origin can't be a null pointer
|
||||||
else if (!origin)
|
else if (!origin)
|
||||||
{
|
|
||||||
origin = _SC("");
|
origin = _SC("");
|
||||||
}
|
|
||||||
// Each event must have an array of parameters (empty or not)
|
// Each event must have an array of parameters (empty or not)
|
||||||
Array parameters(DefaultVM::Get(), count);
|
Array parameters(_SqVM, count);
|
||||||
// Are the any parameters?
|
// Are the any parameters?
|
||||||
if (params && count > 0)
|
if (params && count > 0)
|
||||||
{
|
{
|
||||||
@ -602,10 +570,12 @@ void Session::ForwardEvent(Session * session, Function & listener, CCStr event,
|
|||||||
for (Uint32 i = 0; i < count; ++i)
|
for (Uint32 i = 0; i < count; ++i)
|
||||||
parameters.SetValue(i, params[i]);
|
parameters.SetValue(i, params[i]);
|
||||||
}
|
}
|
||||||
|
// Obtain the initial stack size
|
||||||
|
const StackGuard sg(_SqVM);
|
||||||
// Obtain an object to this session instance without creating a new reference counter!
|
// Obtain an object to this session instance without creating a new reference counter!
|
||||||
ClassType< Session >::PushInstance(DefaultVM::Get(), session);
|
ClassType< Session >::PushInstance(_SqVM, session);
|
||||||
// Obtain the pushed object from the stack
|
// Obtain the pushed object from the stack
|
||||||
Var< Object > var(DefaultVM::Get(), -1);
|
Var< Object > var(_SqVM, -1);
|
||||||
// Call the event with the obtained values
|
// Call the event with the obtained values
|
||||||
listener.Execute< Object &, CSStr, CSStr, Array & >(var.value, event, origin, parameters);
|
listener.Execute< Object &, CSStr, CSStr, Array & >(var.value, event, origin, parameters);
|
||||||
}
|
}
|
||||||
@ -616,29 +586,25 @@ void Session::ForwardEvent(Session * session, Function & listener, Uint32 event,
|
|||||||
{
|
{
|
||||||
// Is there anyone even listening to this event?
|
// Is there anyone even listening to this event?
|
||||||
if (listener.IsNull())
|
if (listener.IsNull())
|
||||||
{
|
|
||||||
return; /* No point in going forward */
|
return; /* No point in going forward */
|
||||||
}
|
|
||||||
// Make sure that the origin can't be a null pointer
|
// Make sure that the origin can't be a null pointer
|
||||||
else if (!origin)
|
else if (!origin)
|
||||||
{
|
|
||||||
origin = _SC("");
|
origin = _SC("");
|
||||||
}
|
|
||||||
// Each event must have an array of parameters (empty or not)
|
// Each event must have an array of parameters (empty or not)
|
||||||
Array parameters(DefaultVM::Get(), count);
|
Array parameters(_SqVM, count);
|
||||||
// Are the any parameters?
|
// Are the any parameters?
|
||||||
if (params && count > 0)
|
if (params && count > 0)
|
||||||
{
|
{
|
||||||
// Transform the parameters into a squirrel array
|
// Transform the parameters into a squirrel array
|
||||||
for (unsigned int i = 0; i < count; ++i)
|
for (unsigned int i = 0; i < count; ++i)
|
||||||
{
|
|
||||||
parameters.SetValue(i, params[i]);
|
parameters.SetValue(i, params[i]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// Obtain the initial stack size
|
||||||
|
const StackGuard sg(_SqVM);
|
||||||
// Obtain an object to this session instance without creating a new reference counter!
|
// Obtain an object to this session instance without creating a new reference counter!
|
||||||
ClassType< Session >::PushInstance(DefaultVM::Get(), session);
|
ClassType< Session >::PushInstance(_SqVM, session);
|
||||||
// Obtain the pushed object from the stack
|
// Obtain the pushed object from the stack
|
||||||
Var< Object > var(DefaultVM::Get(), -1);
|
Var< Object > var(_SqVM, -1);
|
||||||
// Call the event with the obtained values
|
// Call the event with the obtained values
|
||||||
listener.Execute< Object &, Uint32, CSStr, Array & >(var.value, event, origin, parameters);
|
listener.Execute< Object &, Uint32, CSStr, Array & >(var.value, event, origin, parameters);
|
||||||
}
|
}
|
||||||
@ -840,7 +806,7 @@ void Session::OnDccSendReq(irc_session_t * session, CCStr nick, CCStr addr, CCSt
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger Session::CmdMsgF(HSQUIRRELVM vm)
|
SQInteger Session::CmdMsgF(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
// Save the stack top
|
// Obtain the initial stack size
|
||||||
const Int32 top = sq_gettop(vm);
|
const Int32 top = sq_gettop(vm);
|
||||||
// Do we have a target?
|
// Do we have a target?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
@ -908,7 +874,7 @@ SQInteger Session::CmdMsgF(HSQUIRRELVM vm)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger Session::CmdMeF(HSQUIRRELVM vm)
|
SQInteger Session::CmdMeF(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
// Save the stack top
|
// Obtain the initial stack size
|
||||||
const Int32 top = sq_gettop(vm);
|
const Int32 top = sq_gettop(vm);
|
||||||
// Do we have a target?
|
// Do we have a target?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
@ -976,7 +942,7 @@ SQInteger Session::CmdMeF(HSQUIRRELVM vm)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger Session::CmdNoticeF(HSQUIRRELVM vm)
|
SQInteger Session::CmdNoticeF(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
// Save the stack top
|
// Obtain the initial stack size
|
||||||
const Int32 top = sq_gettop(vm);
|
const Int32 top = sq_gettop(vm);
|
||||||
// Do we have a target?
|
// Do we have a target?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
|
@ -84,7 +84,17 @@ protected:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Make sure a valid session exists and throw an error if it doesn't.
|
* Make sure a valid session exists and throw an error if it doesn't.
|
||||||
*/
|
*/
|
||||||
bool Validate() const;
|
void Validate() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* See whether this session is connected to a server and throw an error if not.
|
||||||
|
*/
|
||||||
|
void ValidateConnection() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* See whether this session is NOT! connected to a server and throw an error if it is.
|
||||||
|
*/
|
||||||
|
void IsNotConnected() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether this session is connected to a server or not.
|
* See whether this session is connected to a server or not.
|
||||||
@ -94,16 +104,6 @@ protected:
|
|||||||
return (m_Session && irc_is_connected(m_Session));
|
return (m_Session && irc_is_connected(m_Session));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* See whether this session is connected to a server and throw an error if not.
|
|
||||||
*/
|
|
||||||
bool ConnectedThrow() const;
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* See whether this session is NOT! connected to a server and throw an error if it is.
|
|
||||||
*/
|
|
||||||
bool NotConnected() const;
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate a session instance used by an event and log an error if it's invalid.
|
* Validate a session instance used by an event and log an error if it's invalid.
|
||||||
*/
|
*/
|
||||||
@ -218,10 +218,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Used by the script engine to retrieve the name from instances of this type.
|
* Used by the script engine to retrieve the name from instances of this type.
|
||||||
*/
|
*/
|
||||||
CSStr Typename() const
|
static SQInteger Typename(HSQUIRRELVM vm);
|
||||||
{
|
|
||||||
return _SC("SqIrcSession");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether this session is valid.
|
* See whether this session is valid.
|
||||||
@ -260,8 +257,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetData(Object & data)
|
void SetData(Object & data)
|
||||||
{
|
{
|
||||||
if (Validate())
|
// Validate the handle
|
||||||
m_Data = data;
|
Validate();
|
||||||
|
// Perform the requested operation
|
||||||
|
m_Data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -277,8 +276,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetServer(CSStr server)
|
void SetServer(CSStr server)
|
||||||
{
|
{
|
||||||
if (Validate() && NotConnected())
|
// Validate the handle
|
||||||
m_Server.assign(server);
|
Validate();
|
||||||
|
// Make sure we are allowed to change the server
|
||||||
|
IsNotConnected();
|
||||||
|
// Perform the requested operation
|
||||||
|
m_Server.assign(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -293,9 +296,12 @@ public:
|
|||||||
* Modify the account password.
|
* Modify the account password.
|
||||||
*/
|
*/
|
||||||
void SetPassword(CSStr passwd)
|
void SetPassword(CSStr passwd)
|
||||||
{
|
{ // Validate the handle
|
||||||
if (Validate() && NotConnected())
|
Validate();
|
||||||
m_Passwd.assign(passwd);
|
// Make sure we are allowed to change the server
|
||||||
|
IsNotConnected();
|
||||||
|
// Perform the requested operation
|
||||||
|
m_Passwd.assign(passwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -324,8 +330,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetUser(CSStr user)
|
void SetUser(CSStr user)
|
||||||
{
|
{
|
||||||
if (Validate() && NotConnected())
|
// Validate the handle
|
||||||
m_User.assign(user);
|
Validate();
|
||||||
|
// Make sure we are allowed to change the server
|
||||||
|
IsNotConnected();
|
||||||
|
// Perform the requested operation
|
||||||
|
m_User.assign(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -341,8 +351,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetName(CSStr name)
|
void SetName(CSStr name)
|
||||||
{
|
{
|
||||||
if (Validate() && NotConnected())
|
// Validate the handle
|
||||||
m_Name.assign(name);
|
Validate();
|
||||||
|
// Make sure we are allowed to change the server
|
||||||
|
IsNotConnected();
|
||||||
|
// Perform the requested operation
|
||||||
|
m_Name.assign(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -547,9 +561,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdJoin(CSStr channel)
|
Int32 CmdJoin(CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_join(m_Session, channel, NULL);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_join(m_Session, channel, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -557,9 +572,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdJoin(CSStr channel, CSStr key)
|
Int32 CmdJoin(CSStr channel, CSStr key)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_join(m_Session, channel, key);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_join(m_Session, channel, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -567,9 +583,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdPart(CSStr channel)
|
Int32 CmdPart(CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_part(m_Session, channel);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_part(m_Session, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -577,9 +594,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdInvite(CSStr nick, CSStr channel)
|
Int32 CmdInvite(CSStr nick, CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_invite(m_Session, nick, channel);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_invite(m_Session, nick, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -587,9 +605,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdNames(CSStr channel)
|
Int32 CmdNames(CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_names(m_Session, channel);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_names(m_Session, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -597,9 +616,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdList()
|
Int32 CmdList()
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_list(m_Session, NULL);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_list(m_Session, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -607,9 +627,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdList(CSStr channel)
|
Int32 CmdList(CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_list(m_Session, channel);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_list(m_Session, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -617,9 +638,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdTopic(CSStr channel)
|
Int32 CmdTopic(CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_topic(m_Session, channel, NULL);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_topic(m_Session, channel, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -627,9 +649,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdTopic(CSStr channel, CSStr topic)
|
Int32 CmdTopic(CSStr channel, CSStr topic)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_topic(m_Session, channel, topic);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_topic(m_Session, channel, topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -637,9 +660,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdChannelMode(CSStr channel)
|
Int32 CmdChannelMode(CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_channel_mode(m_Session, channel, NULL);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_channel_mode(m_Session, channel, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -647,9 +671,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdChannelMode(CSStr channel, CSStr mode)
|
Int32 CmdChannelMode(CSStr channel, CSStr mode)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_channel_mode(m_Session, channel, mode);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_channel_mode(m_Session, channel, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -657,9 +682,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdUserMode()
|
Int32 CmdUserMode()
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_user_mode(m_Session, NULL);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_user_mode(m_Session, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -667,9 +693,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdUserMode(CSStr mode)
|
Int32 CmdUserMode(CSStr mode)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_user_mode(m_Session, mode);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_user_mode(m_Session, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -677,9 +704,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdKick(CSStr nick, CSStr channel)
|
Int32 CmdKick(CSStr nick, CSStr channel)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_kick(m_Session, nick, channel, NULL);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_kick(m_Session, nick, channel, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -687,9 +715,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdKick(CSStr nick, CSStr channel, CSStr reason)
|
Int32 CmdKick(CSStr nick, CSStr channel, CSStr reason)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_kick(m_Session, nick, channel, reason);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_kick(m_Session, nick, channel, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -697,9 +726,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdMsg(CSStr nch, CSStr text)
|
Int32 CmdMsg(CSStr nch, CSStr text)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_msg(m_Session, nch, text);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_msg(m_Session, nch, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -707,9 +737,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdMe(CSStr nch, CSStr text)
|
Int32 CmdMe(CSStr nch, CSStr text)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_me(m_Session, nch, text);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_me(m_Session, nch, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -717,9 +748,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdNotice(CSStr nch, CSStr text)
|
Int32 CmdNotice(CSStr nch, CSStr text)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_notice(m_Session, nch, text);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_notice(m_Session, nch, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -727,9 +759,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdCtcpRequest(CSStr nick, CSStr request)
|
Int32 CmdCtcpRequest(CSStr nick, CSStr request)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_ctcp_request(m_Session, nick, request);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_ctcp_request(m_Session, nick, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -737,9 +770,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdCtcpReply(CSStr nick, CSStr reply)
|
Int32 CmdCtcpReply(CSStr nick, CSStr reply)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_ctcp_reply(m_Session, nick, reply);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_ctcp_reply(m_Session, nick, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -752,9 +786,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdWhois(CSStr nick)
|
Int32 CmdWhois(CSStr nick)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_whois(m_Session, nick);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_whois(m_Session, nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -762,9 +797,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdQuit()
|
Int32 CmdQuit()
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_quit(m_Session, NULL);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_quit(m_Session, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -772,9 +808,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 CmdQuit(CSStr reason)
|
Int32 CmdQuit(CSStr reason)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_cmd_quit(m_Session, reason);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_cmd_quit(m_Session, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -782,9 +819,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 SendRaw(CSStr str)
|
Int32 SendRaw(CSStr str)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_send_raw(m_Session, str);
|
ValidateConnection();
|
||||||
return -1;
|
// Send the specified command and return the result
|
||||||
|
return irc_send_raw(m_Session, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -793,9 +831,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 DestroyDcc(Uint32 dccid)
|
Int32 DestroyDcc(Uint32 dccid)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
return irc_dcc_destroy(m_Session, dccid);
|
ValidateConnection();
|
||||||
return -1;
|
// Perform the requested operation and return the result
|
||||||
|
return irc_dcc_destroy(m_Session, dccid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -803,8 +842,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetCtcpVersion(CSStr version)
|
void SetCtcpVersion(CSStr version)
|
||||||
{
|
{
|
||||||
if (ConnectedThrow())
|
// Validate the connection status
|
||||||
irc_set_ctcp_version(m_Session, version);
|
ValidateConnection();
|
||||||
|
// Perform the requested operation
|
||||||
|
irc_set_ctcp_version(m_Session, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -812,9 +853,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 GetErrNo()
|
Int32 GetErrNo()
|
||||||
{
|
{
|
||||||
if (Validate())
|
// Validate the handle
|
||||||
return irc_errno(m_Session);
|
Validate();
|
||||||
return -1;
|
// Return the requested information
|
||||||
|
return irc_errno(m_Session);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -822,9 +864,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
CSStr GetErrStr()
|
CSStr GetErrStr()
|
||||||
{
|
{
|
||||||
if (Validate())
|
// Validate the handle
|
||||||
return irc_strerror(irc_errno(m_Session));
|
Validate();
|
||||||
return _SC("");
|
// Return the requested information
|
||||||
|
return irc_strerror(irc_errno(m_Session));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -832,8 +875,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetOption(Uint32 option)
|
void SetOption(Uint32 option)
|
||||||
{
|
{
|
||||||
if (Validate())
|
// Validate the handle
|
||||||
return irc_option_set(m_Session, option);
|
Validate();
|
||||||
|
// Perform the requested operation and return the result
|
||||||
|
return irc_option_set(m_Session, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -841,8 +886,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void ResetOption(Uint32 option)
|
void ResetOption(Uint32 option)
|
||||||
{
|
{
|
||||||
if (Validate())
|
// Validate the handle
|
||||||
return irc_option_set(m_Session, option);
|
Validate();
|
||||||
|
// Perform the requested operation and return the result
|
||||||
|
return irc_option_set(m_Session, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user