Generate protocols' settings templates by call

This commit is contained in:
Jaidyn Ann 2021-05-20 09:32:52 -05:00
parent 96195039e0
commit 53fe03d2c8
14 changed files with 68 additions and 237 deletions

View File

@ -33,6 +33,9 @@ public:
//! Change settings
virtual status_t UpdateSettings(BMessage*) = 0;
//! Settings menu template
virtual BMessage SettingsTemplate() = 0;
//! Protocol signature
virtual const char* Signature() const = 0;

View File

@ -400,30 +400,9 @@ ProtocolSettings::Delete(const char* account)
void
ProtocolSettings::_Init()
{
// Find protocol add-on
BPath dllPath(fAddOn->Path());
BFile file(dllPath.Path(), B_READ_ONLY);
if (file.InitCheck() < B_OK) {
fStatus = file.InitCheck();
return;
}
BResources resources(&file);
if (resources.InitCheck() != B_OK) {
fStatus = resources.InitCheck();
return;
}
size_t size;
const void* data = resources.LoadResource(B_MESSAGE_TYPE,
kProtocolSettingsTemplate, &size);
if (!data) {
fStatus = B_BAD_VALUE;
return;
}
// Load protocol's settings template
fTemplate->Unflatten((const char*)data);
BMessage settingsTemplate = fAddOn->Protocol()->SettingsTemplate();
*fTemplate = settingsTemplate;
}

150
configure vendored
View File

@ -1,150 +0,0 @@
#!/bin/sh
#
# Copyright 2014-2015, Dario Casalinuovo.
# Copyright 2009, Pier Luigi Fiorini.
# Distributed under the terms of the MIT License.
#
# Authors:
# Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
# Dario Casalinuovo
#
current_dir=`pwd`
defines=""
# Binaries
jambin=`which jam`
rcbin=`which rc`
xresbin=`which xres`
settypebin=`which settype`
mimesetbin=`which mimeset`
setversionbin=`which setversion`
copyattrbin=`which copyattr`
# Check operating system
platform=`uname -s`
release=`uname -r`
echo -n "Checking operating system... "
case "$platform" in
BeOS)
case "$release" in
4.*)
echo "*** BeOS R4 is not supported!"
exit 1
;;
5.*)
echo "*** BeOS R5 is not supported!"
exit 1
;;
6.*)
echo "*** Zeta is not supported!"
exit 1
;;
*)
echo "*** Unsupported BeOS platform!"
exit 1
;;
esac
;;
Haiku)
defines="HAIKU_TARGET_PLATFORM_HAIKU=1"
;;
*)
echo "*** Unsupported $platform operating system!"
exit 1
;;
esac
echo "$platform $release"
# Check whether jam exists
echo -n "Checking whether jam exists... "
if [ -z "$jambin" ]; then
echo "not found"
echo "*** Caya requires jam, please read our Build.txt file."
exit 1
else
echo "found"
fi
# Check for rc
echo -n "Checking for rc... "
if [ -z "$rcbin" ]; then
echo "not found"
exit 1
fi
echo $rcbin
# Check for xres
echo -n "Checking for xres..."
if [ -z "$xresbin" ]; then
echo "not found"
exit 1
fi
echo $xresbin
# Check for settype
echo -n "Checking for settype..."
if [ -z "$settypebin" ]; then
echo "not found"
exit 1
fi
echo $settypebin
# Check for mimeset
echo -n "Checking for mimeset..."
if [ -z "$mimesetbin" ]; then
echo "not found"
exit 1
fi
echo $mimesetbin
# Check for setverion
echo -n "Checking for setversion..."
if [ -z "$setversionbin" ]; then
echo "not found"
exit 1
fi
echo $setversionbin
# Check for copyattr
echo -n "Checking for copyattr..."
if [ -z "$copyattrbin" ]; then
echo "not found"
exit 1
fi
echo $copyattrbin
# Create the build configuration
mkdir -p $current_dir/generated
cat > $current_dir/generated/BuildConfig << EOF
RC = ${rcbin} ;
XRES = ${xresbin} ;
SETTYPE = ${settypebin} ;
MIMESET = ${mimesetbin} ;
SETVERSION = ${setversionbin} ;
COPYATTR = ${copyattrbin} ;
USER_CONFIG_DIRECTORY = $(finddir B_USER_CONFIG_DIRECTORY) ;
SYSTEM_DIRECTORY = $(finddir B_SYSTEM_DIRECTORY) ;
SYSTEM_BIN_DIRECTORY = $(finddir B_SYSTEM_BIN_DIRECTORY) ;
SYSTEM_SERVERS_DIRECTORY = $(finddir B_SYSTEM_SERVERS_DIRECTORY) ;
SYSTEM_ADDONS_DIRECTORY = $(finddir B_SYSTEM_ADDONS_DIRECTORY) ;
SYSTEM_DEVELOP_DIRECTORY = $(finddir B_SYSTEM_DEVELOP_DIRECTORY) ;
SYSTEM_INCLUDE_DIRECTORY = $(finddir B_SYSTEM_HEADERS_DIRECTORY) ;
SYSTEM_DEVELOP_LIB_DIRECTORY = $(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib ;
SYSTEM_LIB_DIRECTORY = $(finddir B_SYSTEM_LIB_DIRECTORY) ;
BEOS_PREFERENCES_DIRECTORY = $(finddir B_BEOS_PREFERENCES_DIRECTORY) ;
PREFERENCES_DIRECTORY = $(finddir B_PREFERENCES_DIRECTORY) ;
USER_PREFERENCES_DIRECTORY = $(finddir B_USER_CONFIG_DIRECTORY)/be/Preferences ;
APPS_DIRECTORY = $(finddir B_USER_APPS_DIRECTORY) ;
CAYA_DIRECTORY = $(finddir B_USER_APPS_DIRECTORY)/Caya ;
DEFINES += ${defines} ;
EOF
echo $USER_CONFIG_DIRECTORY
echo $SYSTEM_DEVELOP_DIRECTORY
echo "Configuration done."

View File

@ -30,6 +30,13 @@ FacebookProtocol::OverrideSettings()
}
BMessage
FacebookProtocol::SettingsTemplate()
{
return JabberHandler::_SettingsTemplate("Username", false);
}
BString
FacebookProtocol::ComposeJID() const
{

View File

@ -31,6 +31,13 @@ GoogleTalkProtocol::OverrideSettings()
}
BMessage
GoogleTalkProtocol::SettingsTemplate()
{
return JabberHandler::_SettingsTemplate("Identifier", false);
}
BString
GoogleTalkProtocol::ComposeJID() const
{

View File

@ -13,6 +13,8 @@ public:
virtual ~GoogleTalkProtocol();
virtual void OverrideSettings();
virtual BMessage SettingsTemplate();
virtual BString ComposeJID() const;
};

View File

@ -699,6 +699,42 @@ JabberHandler::_GlooxStatusToCaya(gloox::Presence::PresenceType type)
}
BMessage
JabberHandler::_SettingsTemplate(const char* username, bool serverOption)
{
BMessage stemplate('IMst');
BMessage usernameText;
usernameText.AddString("name", "username");
usernameText.AddString("description", username);
usernameText.AddInt32("type", 'CSTR');
stemplate.AddMessage("setting", &usernameText);
BMessage passwordText;
passwordText.AddString("name", "password");
passwordText.AddString("description", "Password");
passwordText.AddInt32("type", 'CSTR');
passwordText.AddBool("is_secret", true);
stemplate.AddMessage("setting", &passwordText);
BMessage serverText;
serverText.AddString("name", "server");
serverText.AddString("description", "Server");
serverText.AddInt32("type", 'CSTR');
if (serverOption == true)
stemplate.AddMessage("setting", &serverText);
BMessage resourceText;
resourceText.AddString("name", "resource");
resourceText.AddString("description", "Resource");
resourceText.AddInt32("type", 'CSTR');
resourceText.AddString("default", "Caya");
stemplate.AddMessage("setting", &resourceText);
return stemplate;
}
/***********************************************************************
* gloox callbacks
**********************************************************************/

View File

@ -74,6 +74,7 @@ protected:
BString fResource;
uint16 fPort;
BMessage _SettingsTemplate(const char* username, bool serverOption);
private:
CayaProtocolMessengerInterface*
fServerMessenger;

View File

@ -8,6 +8,7 @@
#include "JabberProtocol.h"
const char* kProtocolSignature = "jabber";
const char* kProtocolName = "Jabber";
@ -29,6 +30,13 @@ JabberProtocol::OverrideSettings()
}
BMessage
JabberProtocol::SettingsTemplate()
{
return JabberHandler::_SettingsTemplate("Jabber identifier", true);
}
BString
JabberProtocol::ComposeJID() const
{

View File

@ -13,6 +13,7 @@ public:
virtual ~JabberProtocol();
virtual void OverrideSettings();
virtual BMessage SettingsTemplate();
virtual BString ComposeJID() const;
};

View File

@ -40,8 +40,7 @@ SRCS = \
# Specify the resource definition files to use. Full or relative paths can be
# used.
RDEFS = \
protocols/xmpp/jabber.rdef \
protoocls/xmpp/jabber_settings.rdef
protocols/xmpp/jabber.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.

View File

@ -1,19 +0,0 @@
resource(1000) message('IMst') {
"setting" = message {
"name" = "username",
"description" = "Username",
int32 "type" = 'CSTR'
},
"setting" = message {
"name" = "password",
"description" = "Password",
int32 "type" = 'CSTR',
"is_secret" = true
},
"setting" = message {
"name" = "resource",
"description" = "Resource",
int32 "type" = 'CSTR',
"default" = "Caya"
}
};

View File

@ -1,19 +0,0 @@
resource(1000) message('IMst') {
"setting" = message {
"name" = "username",
"description" = "Identifier",
int32 "type" = 'CSTR'
},
"setting" = message {
"name" = "password",
"description" = "Password",
int32 "type" = 'CSTR',
"is_secret" = true
},
"setting" = message {
"name" = "resource",
"description" = "Resource",
int32 "type" = 'CSTR',
"default" = "Caya"
}
};

View File

@ -1,24 +0,0 @@
resource(1000) message('IMst') {
"setting" = message {
"name" = "username",
"description" = "Jabber identifier",
int32 "type" = 'CSTR'
},
"setting" = message {
"name" = "password",
"description" = "Password",
int32 "type" = 'CSTR',
"is_secret" = true
},
"setting" = message {
"name" = "server",
"description" = "Server",
int32 "type" = 'CSTR'
},
"setting" = message {
"name" = "resource",
"description" = "Resource",
int32 "type" = 'CSTR',
"default" = "Caya"
}
};