2021-06-20 22:17:24 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
|
|
*/
|
|
|
|
#ifndef _IRC_PROTOCOL_H
|
|
|
|
#define _IRC_PROTOCOL_H
|
|
|
|
|
|
|
|
#include <Path.h>
|
|
|
|
#include <Resources.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
#include <libircclient.h>
|
|
|
|
#include <libirc_rfcnumeric.h>
|
|
|
|
|
|
|
|
#include <ChatProtocol.h>
|
|
|
|
|
|
|
|
|
|
|
|
status_t connect_thread(void* data);
|
|
|
|
|
|
|
|
|
2021-06-21 01:54:42 -05:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BString nick;
|
|
|
|
BString id;
|
|
|
|
} irc_ctx_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-20 22:17:24 -05:00
|
|
|
class IrcProtocol : public ChatProtocol {
|
|
|
|
public:
|
|
|
|
IrcProtocol();
|
|
|
|
|
|
|
|
// ChatProtocol inheritance
|
|
|
|
virtual status_t Init(ChatProtocolMessengerInterface* interface);
|
|
|
|
virtual status_t Shutdown();
|
|
|
|
|
|
|
|
virtual status_t Process(BMessage* msg);
|
|
|
|
|
|
|
|
virtual status_t UpdateSettings(BMessage* msg);
|
|
|
|
virtual BMessage SettingsTemplate(const char* name);
|
|
|
|
|
|
|
|
virtual BObjectList<BMessage> Commands();
|
|
|
|
virtual BObjectList<BMessage> UserPopUpItems();
|
|
|
|
virtual BObjectList<BMessage> ChatPopUpItems();
|
|
|
|
virtual BObjectList<BMessage> MenuBarItems();
|
|
|
|
|
|
|
|
virtual const char* Signature() const;
|
|
|
|
virtual const char* FriendlySignature() const;
|
|
|
|
|
|
|
|
virtual BBitmap* Icon() const;
|
|
|
|
|
|
|
|
virtual void SetAddOnPath(BPath path);
|
|
|
|
virtual BPath AddOnPath();
|
|
|
|
|
|
|
|
virtual const char* GetName();
|
|
|
|
virtual void SetName(const char* name);
|
|
|
|
|
|
|
|
virtual uint32 GetEncoding();
|
|
|
|
|
|
|
|
virtual ChatProtocolMessengerInterface*
|
|
|
|
MessengerInterface() const;
|
2021-06-21 01:54:42 -05:00
|
|
|
// IRC
|
|
|
|
BMessage* fSettings;
|
|
|
|
irc_session_t* fSession;
|
2021-06-20 22:17:24 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
ChatProtocolMessengerInterface* fMessenger;
|
|
|
|
|
|
|
|
thread_id fServerThread;
|
|
|
|
|
|
|
|
BString fName;
|
|
|
|
BPath fAddOnPath;
|
|
|
|
BResources fResources;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
irc_callbacks_t get_callbacks();
|
|
|
|
|
|
|
|
void event_connect(irc_session_t* session, const char* event,
|
|
|
|
const char* origin, const char** params,
|
|
|
|
unsigned int count);
|
|
|
|
|
2021-06-21 01:54:42 -05:00
|
|
|
void event_numeric(irc_session_t* session, unsigned int event,
|
2021-06-20 22:17:24 -05:00
|
|
|
const char* origin, const char** params, unsigned int count);
|
|
|
|
|
|
|
|
void event_join(irc_session_t* session, const char* event,
|
2021-06-21 01:54:42 -05:00
|
|
|
const char* joiner, const char** channel, unsigned int count);
|
|
|
|
void event_part(irc_session_t* session, const char* event,
|
|
|
|
const char* quitter, const char** chanReason, unsigned int count);
|
|
|
|
|
|
|
|
void event_channel(irc_session_t* session, const char* event,
|
|
|
|
const char* sender, const char** chanBody, unsigned int count);
|
|
|
|
void event_privmsg(irc_session_t* session, const char* event,
|
|
|
|
const char* sender, const char** selfBody, unsigned int count);
|
|
|
|
|
|
|
|
void event_nick(irc_session_t* session, const char* event,
|
|
|
|
const char* oldNick, const char** newNick, unsigned int count);
|
|
|
|
|
|
|
|
|
|
|
|
BString _UserNick(const char* userId);
|
|
|
|
bool _IsOwnUser(const char* userId, irc_session_t* session);
|
2021-06-20 22:17:24 -05:00
|
|
|
|
2021-06-21 01:54:42 -05:00
|
|
|
void _SendMessage(BMessage* msg);
|
2021-06-20 22:17:24 -05:00
|
|
|
|
|
|
|
#endif // _IRC_PROTOCOL_H
|