static gboolean handle_mime_object (MuMsg *msg, GMimeObject *mobj, GMimeObject *parent, MuMsgOptions opts, unsigned *index, gboolean decrypted, MuMsgPartForeachFunc func, gpointer user_data) { if (GMIME_IS_PART (mobj)) return handle_part (msg, GMIME_PART(mobj), parent, opts, index, decrypted, func, user_data); else if (GMIME_IS_MESSAGE_PART (mobj)) return handle_message_part (msg, GMIME_MESSAGE_PART(mobj), parent, opts, index, decrypted, func, user_data); else if ((opts & MU_MSG_OPTION_VERIFY) && GMIME_IS_MULTIPART_SIGNED (mobj)) { check_signature (msg, GMIME_MULTIPART_SIGNED (mobj), opts); return handle_multipart (msg, GMIME_MULTIPART (mobj), mobj, opts, index, decrypted, func, user_data); } else if ((opts & MU_MSG_OPTION_DECRYPT) && GMIME_IS_MULTIPART_ENCRYPTED (mobj)) return handle_encrypted_part (msg, GMIME_MULTIPART_ENCRYPTED (mobj), opts, index, func, user_data); else if (GMIME_IS_MULTIPART (mobj)) return handle_multipart (msg, GMIME_MULTIPART (mobj), parent, opts, index, decrypted, func, user_data); return TRUE; }
static bool dispatch_handler(int fd, struct ircmsg *msg) { switch (msg->type) { case IRCMSG_UNKNOWN: return true; case IRCMSG_PING: return handle_ping(fd, &msg->u.ping); case IRCMSG_PART: return handle_part(fd, &msg->u.part); case IRCMSG_JOIN: return handle_join(fd, &msg->u.join); case IRCMSG_PRIVMSG: return handle_privmsg(fd, &msg->u.privmsg); case IRCMSG_KICK: return handle_kick(fd, &msg->u.kick); default: return false; } }
static gboolean handle_mime_object (MuMsg *msg, GMimeObject *mobj, GMimeObject *parent, MuMsgOptions opts, unsigned index, MuMsgPartForeachFunc func, gpointer user_data) { if (GMIME_IS_PART (mobj)) return handle_part (msg, GMIME_PART(mobj), parent, opts, index, func, user_data); else if (GMIME_IS_MESSAGE_PART (mobj)) return handle_message_part (msg, GMIME_MESSAGE_PART(mobj), parent, opts, index, func, user_data); else if (GMIME_IS_MULTIPART_SIGNED (mobj)) return handle_signed_part (msg, GMIME_MULTIPART_SIGNED (mobj), parent, opts, index, func, user_data); else if (GMIME_IS_MULTIPART_ENCRYPTED (mobj)) return handle_encrypted_part (msg, GMIME_MULTIPART_ENCRYPTED (mobj), parent, opts, index, func, user_data); return TRUE; }
void ircInterface::onMessage(std::string msg){ /* while(pkge.find("\r\n") != std::string::npos){ std::string msg = pkge.substr(0, pkge.find("\r\n")); pkge = pkge.substr(pkge.find("\r\n") + 2); */ //std::cout << "ircInterface: raw message is : "<<msg<<std::endl; ircLog::instance()->logf(FILENAME, "raw message is: %s", msg.c_str()); //alot of the control strings will start with the type sperated from the //contents of the message with a space std::string type = msg.substr(0, msg.find_first_of(' ')); //first check for messages that start with message names //check for ping if(!type.compare(PING)) { _connStatus->pingRcvd(); sendPong(); return; } else if(!type.compare(ERROR)) { //TODO need to figure out hwat to do here //for now lets just try and not spam the other levels return; } else if(!type.compare("IRCERROR")) { //handle connection errors in conn status _connStatus->connectionIoError(); } //now check for messages that start with nicks or server titles else { _connStatus->pingRcvd(); //type is actually a prefix containing the host mask etc std::string prefix = type; // the actual message past the prefix msg = msg.substr(msg.find_first_of(' ')+1); //the first part of that message should be the type type = msg.substr(0, msg.find_first_of(' ')); //check first to see if it is a private message //most irc messaages are private messages if(!type.compare(PRIVMSG)) { handle_privmsg(msg, prefix); } else if(!type.compare(NOTICE)) { if(_connStatus->state() == CS_IDLE) { _connStatus->connected(); } handle_notice(msg, prefix); } else if(!type.compare(QUIT)) { ircEvent e = handle_quit(msg, prefix); notifyEvent(e); } else if(!type.compare(JOIN)) { ircEvent e = handle_join(msg, prefix); notifyEvent(e); } else if(!type.compare(PART)) { ircEvent e = handle_part(msg, prefix); notifyEvent(e); } else if(!type.compare(NICK)) { ircEvent e = handle_nick(msg, prefix); notifyEvent(e); } else if(!type.compare(INSPIRCDVARS)) { handle_vars(msg); } else if(!type.compare(NICKLIST)) { //add function to parse the nicklist std::vector<ircEvent> e = handle_nicklist(msg); for(unsigned int i = 0; i < e.size(); ++i) { notifyEvent(e[i]); } } else if(!type.compare("001")) { _connStatus->registered(); } } // } }