From b52be74dfbc2558836705fec742183e99099d144 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Tue, 22 Jun 2021 14:42:07 -0500 Subject: [PATCH] Init libpurple add-on --- protocols/Makefile | 3 + protocols/purple/Makefile | 139 +++++++++++++++++++++++++ protocols/purple/PurpleMain.cpp | 65 ++++++++++++ protocols/purple/PurpleProtocol.cpp | 156 ++++++++++++++++++++++++++++ protocols/purple/PurpleProtocol.h | 72 +++++++++++++ protocols/purple/purple.rdef | 13 +++ 6 files changed, 448 insertions(+) create mode 100644 protocols/purple/Makefile create mode 100644 protocols/purple/PurpleMain.cpp create mode 100644 protocols/purple/PurpleProtocol.cpp create mode 100644 protocols/purple/PurpleProtocol.h create mode 100644 protocols/purple/purple.rdef diff --git a/protocols/Makefile b/protocols/Makefile index 14d1f28..e74f33e 100644 --- a/protocols/Makefile +++ b/protocols/Makefile @@ -3,6 +3,9 @@ irc: $(MAKE) -f protocols/irc/Makefile +purple: + $(MAKE) -f protocols/purple/Makefile + xmpp: $(MAKE) -f protocols/xmpp/Makefile diff --git a/protocols/purple/Makefile b/protocols/purple/Makefile new file mode 100644 index 0000000..077c4b1 --- /dev/null +++ b/protocols/purple/Makefile @@ -0,0 +1,139 @@ +## Haiku Generic Makefile v2.6 ## + +## Fill in this file to specify the project being created, and the referenced +## Makefile-Engine will do all of the hard work for you. This handles any +## architecture of Haiku. +## +## For more information, see: +## file:///system/develop/documentation/makefile-engine.html + +# The name of the binary. +NAME = protocols/purple + +# The type of binary, must be one of: +# APP: Application +# SHARED: Shared library or add-on +# STATIC: Static library archive +# DRIVER: Kernel driver +TYPE = SHARED + +# If you plan to use localization, specify the application's MIME signature. +APP_MIME_SIG = + +# The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are +# so that Pe and Eddie can fill them in for you. +#%{ +# @src->@ + +# Specify the source files to use. Full paths or paths relative to the +# Makefile can be included. All files, regardless of directory, will have +# their object files created in the common object directory. Note that this +# means this Makefile will not work correctly if two source files with the +# same name (source.c or source.cpp) are included from different directories. +# Also note that spaces in folder names do not work well with this Makefile. +SRCS = \ + protocols/purple/PurpleMain.cpp \ + protocols/purple/PurpleProtocol.cpp \ + +# Specify the resource definition files to use. Full or relative paths can be +# used. +RDEFS = \ + protocols/purple/purple.rdef + +# Specify the resource files to use. Full or relative paths can be used. +# Both RDEFS and RSRCS can be utilized in the same Makefile. +RSRCS = + +# End Pe/Eddie support. +# @<-src@ +#%} + +# Specify libraries to link against. +# There are two acceptable forms of library specifications: +# - if your library follows the naming pattern of libXXX.so or libXXX.a, +# you can simply specify XXX for the library. (e.g. the entry for +# "libtracker.so" would be "tracker") +# +# - for GCC-independent linking of standard C++ libraries, you can use +# $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names. +# +# - if your library does not follow the standard library naming scheme, +# you need to specify the path to the library and it's name. +# (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") +LIBS = be crypto network support purple glib-2.0 $(STDCPPLIBS) + + +# Specify additional paths to directories following the standard libXXX.so +# or libXXX.a naming scheme. You can specify full paths or paths relative +# to the Makefile. The paths included are not parsed recursively, so +# include all of the paths where libraries must be found. Directories where +# source files were specified are automatically included. +LIBPATHS = + +# Additional paths to look for system headers. These use the form +# "#include
". Directories that contain the files in SRCS are +# NOT auto-included here. +SYSTEM_INCLUDE_PATHS = libs/ application/ \ + $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY libpurple) + +# Additional paths paths to look for local headers. These use the form +# #include "header". Directories that contain the files in SRCS are +# automatically included. +LOCAL_INCLUDE_PATHS = + +# Specify the level of optimization that you want. Specify either NONE (O0), +# SOME (O1), FULL (O3), or leave blank (for the default optimization level). +OPTIMIZE := + +# Specify the codes for languages you are going to support in this +# application. The default "en" one must be provided too. "make catkeys" +# will recreate only the "locales/en.catkeys" file. Use it as a template +# for creating catkeys for other languages. All localization files must be +# placed in the "locales" subdirectory. +LOCALES = + +# Specify all the preprocessor symbols to be defined. The symbols will not +# have their values set automatically; you must supply the value (if any) to +# use. For example, setting DEFINES to "DEBUG=1" will cause the compiler +# option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass +# "-DDEBUG" on the compiler's command line. +DEFINES = + +# Specify the warning level. Either NONE (suppress all warnings), +# ALL (enable all warnings), or leave blank (enable default warnings). +WARNINGS = + +# With image symbols, stack crawls in the debugger are meaningful. +# If set to "TRUE", symbols will be created. +SYMBOLS := + +# Includes debug information, which allows the binary to be debugged easily. +# If set to "TRUE", debug info will be created. +DEBUGGER := + +# Specify any additional compiler flags to be used. +COMPILER_FLAGS = $(shell pkg-config --cflags glib-2.0) + + +# Specify any additional linker flags to be used. +LINKER_FLAGS = + +# Specify the version of this binary. Example: +# -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL" +# This may also be specified in a resource. +APP_VERSION := + +# (Only used when "TYPE" is "DRIVER"). Specify the desired driver install +# location in the /dev hierarchy. Example: +# DRIVER_PATH = video/usb +# will instruct the "driverinstall" rule to place a symlink to your driver's +# binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will +# appear at /dev/video/usb when loaded. The default is "misc". +DRIVER_PATH = + +## Include the Makefile-Engine +DEVEL_DIRECTORY := /boot/system/develop/ +include $(DEVEL_DIRECTORY)/etc/makefile-engine + +include Makefile.common +include protocols/Makefile.common diff --git a/protocols/purple/PurpleMain.cpp b/protocols/purple/PurpleMain.cpp new file mode 100644 index 0000000..55b7741 --- /dev/null +++ b/protocols/purple/PurpleMain.cpp @@ -0,0 +1,65 @@ +/* + Copyright 2021, Jaidyn Levesque + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "PurpleProtocol.h" + + +extern "C" _EXPORT ChatProtocol* protocol_at(int32 i); +extern "C" _EXPORT int32 protocol_count(); +extern "C" _EXPORT const char* signature(); +extern "C" _EXPORT const char* friendly_signature(); +extern "C" _EXPORT uint32 version(); + + +ChatProtocol* +protocol_at(int32 i) +{ + if (i == 0) + return (ChatProtocol*)new PurpleProtocol(); + return NULL; +} + + +int32 +protocol_count() +{ + return 1; +} + + +const char* +signature() +{ + return "purple"; +} + + +const char* +friendly_signature() +{ + return "Purple"; +} + + +uint32 +version() +{ + return APP_VERSION_1_PRE_ALPHA_1; +} + + diff --git a/protocols/purple/PurpleProtocol.cpp b/protocols/purple/PurpleProtocol.cpp new file mode 100644 index 0000000..e5dcda6 --- /dev/null +++ b/protocols/purple/PurpleProtocol.cpp @@ -0,0 +1,156 @@ +/* + Copyright 2021, Jaidyn Levesque + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "PurpleProtocol.h" + +#include + +#include + +#include + + +PurpleProtocol::PurpleProtocol() +{ +} + + +status_t +PurpleProtocol::Init(ChatProtocolMessengerInterface* interface) +{ + fMessenger = interface; + return B_OK; +} + + +status_t +PurpleProtocol::Shutdown() +{ + return B_OK; +} + + +status_t +PurpleProtocol::Process(BMessage* msg) +{ + return B_OK; +} + + +status_t +PurpleProtocol::UpdateSettings(BMessage* msg) +{ + return B_OK; +} + + +BMessage +PurpleProtocol::SettingsTemplate(const char* name) +{ + return BMessage(); +} + + +BObjectList +PurpleProtocol::Commands() +{ + return BObjectList(); +} + + +BObjectList +PurpleProtocol::UserPopUpItems() +{ + return BObjectList(); +} + + +BObjectList +PurpleProtocol::ChatPopUpItems() +{ + return BObjectList(); +} + +BObjectList +PurpleProtocol::MenuBarItems() +{ + return BObjectList(); +} + + +const char* +PurpleProtocol::Signature() const +{ + return "purple"; +} + + +const char* +PurpleProtocol::FriendlySignature() const +{ + return "Purple"; +} + + +BBitmap* +PurpleProtocol::Icon() const +{ + return NULL; +} + + +void +PurpleProtocol::SetAddOnPath(BPath path) +{ + fAddOnPath = path; +} + + +BPath +PurpleProtocol::AddOnPath() +{ + return fAddOnPath; +} + + +const char* +PurpleProtocol::GetName() +{ + return fName.String(); +} + + +void +PurpleProtocol::SetName(const char* name) +{ + fName.SetTo(name); +} + + +uint32 +PurpleProtocol::GetEncoding() +{ + return 0xffff; +} + + +ChatProtocolMessengerInterface* +PurpleProtocol::MessengerInterface() const +{ + return fMessenger; +} diff --git a/protocols/purple/PurpleProtocol.h b/protocols/purple/PurpleProtocol.h new file mode 100644 index 0000000..82940f4 --- /dev/null +++ b/protocols/purple/PurpleProtocol.h @@ -0,0 +1,72 @@ +/* + Copyright 2021, Jaidyn Levesque + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef _PURPLE_PROTOCOL_H +#define _PURPLE_PROTOCOL_H + +#include +#include + +#include + + +class PurpleProtocol : public ChatProtocol { +public: + PurpleProtocol(); + + // 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 Commands(); + virtual BObjectList UserPopUpItems(); + virtual BObjectList ChatPopUpItems(); + virtual BObjectList 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; + +private: + ChatProtocolMessengerInterface* fMessenger; + + thread_id fServerThread; + + BString fName; + BPath fAddOnPath; +}; + + +#endif // _PURPLE_PROTOCOL_H diff --git a/protocols/purple/purple.rdef b/protocols/purple/purple.rdef new file mode 100644 index 0000000..3c77956 --- /dev/null +++ b/protocols/purple/purple.rdef @@ -0,0 +1,13 @@ + +resource app_version { + major = 0, + middle = 0, + minor = 1, + + variety = B_APPV_ALPHA, + internal = 0, + + short_info = "Libpurple add-on for Cardie", + long_info = "©2021 Jaidyn Levesque" +}; +