mirror of
https://github.com/glest/glest-source.git
synced 2025-08-23 16:32:53 +02:00
- attempt to avoid IRC client crashes on Internet menu if user does not have an Internet connection
This commit is contained in:
@@ -31,9 +31,14 @@ namespace Shared { namespace PlatformCommon {
|
||||
// class IRCThreadThread
|
||||
// =====================================================
|
||||
|
||||
enum IRCEventType {
|
||||
IRC_evt_chatText = 0,
|
||||
IRC_evt_exitThread = 1
|
||||
};
|
||||
|
||||
class IRCCallbackInterface {
|
||||
public:
|
||||
virtual void IRC_CallbackEvent(const char* origin, const char **params, unsigned int count) = 0;
|
||||
virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count) = 0;
|
||||
};
|
||||
|
||||
class IRCThread : public BaseThread
|
||||
@@ -51,6 +56,7 @@ protected:
|
||||
time_t lastNickListUpdate;
|
||||
std::vector<string> eventData;
|
||||
|
||||
Mutex mutexIRCCB;
|
||||
IRCCallbackInterface *callbackObj;
|
||||
|
||||
public:
|
||||
@@ -84,7 +90,8 @@ public:
|
||||
std::vector<string> & getCachedNickList() { return eventData; }
|
||||
void setCachedNickList(std::vector<string> &list) { eventData = list; }
|
||||
|
||||
IRCCallbackInterface * getCallbackObj() { return callbackObj;}
|
||||
IRCCallbackInterface * getCallbackObj();
|
||||
void setCallbackObj(IRCCallbackInterface *cb);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -192,7 +192,7 @@ void event_channel(irc_session_t * session, const char * event, const char * ori
|
||||
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||
if(ctx != NULL) {
|
||||
if(ctx->getCallbackObj() != NULL) {
|
||||
ctx->getCallbackObj()->IRC_CallbackEvent(nickbuf, params, count);
|
||||
ctx->getCallbackObj()->IRC_CallbackEvent(IRC_evt_chatText, nickbuf, params, count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,6 +411,15 @@ std::vector<string> IRCThread::getNickList() {
|
||||
return nickList;
|
||||
}
|
||||
|
||||
IRCCallbackInterface * IRCThread::getCallbackObj() {
|
||||
MutexSafeWrapper safeMutex(&mutexIRCCB);
|
||||
return callbackObj;
|
||||
}
|
||||
void IRCThread::setCallbackObj(IRCCallbackInterface *cb) {
|
||||
MutexSafeWrapper safeMutex(&mutexIRCCB);
|
||||
callbackObj=cb;
|
||||
}
|
||||
|
||||
void IRCThread::execute() {
|
||||
{
|
||||
RunningStatusSafeWrapper runningStatus(this);
|
||||
@@ -509,6 +518,9 @@ void IRCThread::execute() {
|
||||
|
||||
// Delete ourself when the thread is done (no other actions can happen after this
|
||||
// such as the mutex which modifies the running status of this method
|
||||
if(getCallbackObj() != NULL) {
|
||||
getCallbackObj()->IRC_CallbackEvent(IRC_evt_exitThread, NULL, NULL, 0);
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user