Reorganize settings directory, custom purple paths
The settings file-hierarchy has been changed a bit: * Cardie/ * preferences * Accounts/ * Cache/ * Accounts/ * Add-Ons/ `Cardie/Protocols` is now `Cardie/Accounts`, and the cache directory has been split into two. `Cache/Accounts/` is for account-specific cached data (e.g., cached roster icons, data, etc.), and `Cache/Protocols` is for protocol-wide settings/data. For purple, this will be used as the user's libpurple directory, which has been moved from the default of `~/.purple` (yikes!) Some plugin search-paths have been given to purple, too― lib directories + "/purple2/", and Cardie/Cache/Add-Ons/purple/plugins/.
This commit is contained in:
parent
f5b90ecc5e
commit
d883c23d18
|
@ -118,25 +118,7 @@ AccountsPath()
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path.Append(APP_NAME "/Protocols");
|
path.Append(APP_NAME "/Accounts");
|
||||||
if (create_directory(path.Path(), 0755) != B_OK)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return path.Path();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char*
|
|
||||||
AccountPath(const char* signature)
|
|
||||||
{
|
|
||||||
if (!signature)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
BPath path(AccountsPath());
|
|
||||||
if (path.InitCheck() != B_OK)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
path.Append(signature);
|
|
||||||
if (create_directory(path.Path(), 0755) != B_OK)
|
if (create_directory(path.Path(), 0755) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -147,16 +129,17 @@ AccountPath(const char* signature)
|
||||||
const char*
|
const char*
|
||||||
AccountPath(const char* signature, const char* subsignature)
|
AccountPath(const char* signature, const char* subsignature)
|
||||||
{
|
{
|
||||||
if (BString(signature) == BString(subsignature)
|
BPath path(AccountsPath());
|
||||||
|| BString(subsignature).IsEmpty() == true)
|
if (path.InitCheck() != B_OK)
|
||||||
return AccountPath(signature);
|
|
||||||
|
|
||||||
BPath path(AccountPath(signature));
|
|
||||||
|
|
||||||
path.Append(subsignature);
|
|
||||||
if (create_directory(path.Path(), 0755) != B_OK)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
path.Append(signature);
|
||||||
|
if (BString(signature) != BString(subsignature)
|
||||||
|
&& BString(subsignature).IsEmpty() == false)
|
||||||
|
path.Append(subsignature);
|
||||||
|
|
||||||
|
if (create_directory(path.Path(), 0755) != B_OK)
|
||||||
|
return NULL;
|
||||||
return path.Path();
|
return path.Path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +161,7 @@ const char*
|
||||||
AccountCachePath(const char* accountName)
|
AccountCachePath(const char* accountName)
|
||||||
{
|
{
|
||||||
BPath path(CachePath());
|
BPath path(CachePath());
|
||||||
|
path.Append("Accounts");
|
||||||
if (path.InitCheck() != B_OK)
|
if (path.InitCheck() != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
path.Append(accountName);
|
path.Append(accountName);
|
||||||
|
|
|
@ -31,7 +31,6 @@ BMenu* CreateAccountMenu(AccountInstances accounts, BMessage msg,
|
||||||
BMessage* allMsg = NULL);
|
BMessage* allMsg = NULL);
|
||||||
|
|
||||||
const char* AccountsPath();
|
const char* AccountsPath();
|
||||||
const char* AccountPath(const char* signature);
|
|
||||||
const char* AccountPath(const char* signature, const char* subsignature);
|
const char* AccountPath(const char* signature, const char* subsignature);
|
||||||
|
|
||||||
const char* CachePath();
|
const char* CachePath();
|
||||||
|
|
|
@ -20,5 +20,6 @@
|
||||||
#define _PURPLE_H
|
#define _PURPLE_H
|
||||||
|
|
||||||
#define PURPLE_SIGNATURE "application/x-vnd.cardie.purple"
|
#define PURPLE_SIGNATURE "application/x-vnd.cardie.purple"
|
||||||
|
#define PURPLE_ADDON "purple"
|
||||||
|
|
||||||
#endif // _PURPLE_H
|
#endif // _PURPLE_H
|
||||||
|
|
|
@ -26,7 +26,9 @@
|
||||||
#include <libpurple/purple.h>
|
#include <libpurple/purple.h>
|
||||||
#include <libpurple/status.h>
|
#include <libpurple/status.h>
|
||||||
|
|
||||||
|
#include <Directory.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
|
#include <Path.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
|
|
||||||
#include <Cardie.h>
|
#include <Cardie.h>
|
||||||
|
@ -85,7 +87,6 @@ PurpleApp::MessageReceived(BMessage* msg)
|
||||||
protocolInfo.AddString("name", info->name);
|
protocolInfo.AddString("name", info->name);
|
||||||
protocolInfo.AddString("id", info->id);
|
protocolInfo.AddString("id", info->id);
|
||||||
SendMessage(thread_id, protocolInfo);
|
SendMessage(thread_id, protocolInfo);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PURPLE_CONNECT_ACCOUNT:
|
case PURPLE_CONNECT_ACCOUNT:
|
||||||
|
@ -495,6 +496,14 @@ init_libpurple()
|
||||||
{
|
{
|
||||||
init_ui_ops();
|
init_ui_ops();
|
||||||
|
|
||||||
|
purple_util_set_user_dir(purple_cache());
|
||||||
|
|
||||||
|
|
||||||
|
BString cachePlugin = BString(purple_cache()).Append("/plugins/");
|
||||||
|
purple_plugins_add_search_path(cachePlugin.String());
|
||||||
|
purple_plugins_add_finddir(B_USER_NONPACKAGED_LIB_DIRECTORY);
|
||||||
|
purple_plugins_add_finddir(B_SYSTEM_NONPACKAGED_LIB_DIRECTORY);
|
||||||
|
|
||||||
if (!purple_core_init(PURPLE_UI_ID))
|
if (!purple_core_init(PURPLE_UI_ID))
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
@ -643,7 +652,6 @@ signal_sent_im_msg(PurpleAccount* account, const char* receiver,
|
||||||
sent.AddString("chat_id", receiver);
|
sent.AddString("chat_id", receiver);
|
||||||
sent.AddString("user_id", purple_account_get_username(account));
|
sent.AddString("user_id", purple_account_get_username(account));
|
||||||
sent.AddString("body", message);
|
sent.AddString("body", message);
|
||||||
sent.PrintToStream();
|
|
||||||
((PurpleApp*)be_app)->SendMessage(account, sent);
|
((PurpleApp*)be_app)->SendMessage(account, sent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,6 +726,30 @@ purple_status_to_cardie(PurpleStatus* status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
purple_cache()
|
||||||
|
{
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||||
|
return NULL;
|
||||||
|
path.Append(APP_NAME "/Cache/Add-Ons/" PURPLE_ADDON);
|
||||||
|
if (create_directory(path.Path(), 0755) != B_OK)
|
||||||
|
return NULL;
|
||||||
|
return path.Path();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
purple_plugins_add_finddir(directory_which finddir)
|
||||||
|
{
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(finddir, &path) == B_OK) {
|
||||||
|
path.Append("purple2");
|
||||||
|
purple_plugins_add_search_path(path.Path());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static guint _purple_glib_input_add(gint fd, PurpleInputCondition condition,
|
static guint _purple_glib_input_add(gint fd, PurpleInputCondition condition,
|
||||||
PurpleInputFunction function, gpointer data)
|
PurpleInputFunction function, gpointer data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <libpurple/purple.h>
|
#include <libpurple/purple.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
#include <StringList.h>
|
#include <StringList.h>
|
||||||
|
|
||||||
|
@ -128,6 +129,9 @@ private:
|
||||||
PurpleStatusPrimitive cardie_status_to_purple(UserStatus status);
|
PurpleStatusPrimitive cardie_status_to_purple(UserStatus status);
|
||||||
UserStatus purple_status_to_cardie(PurpleStatus* status);
|
UserStatus purple_status_to_cardie(PurpleStatus* status);
|
||||||
|
|
||||||
|
const char* purple_cache();
|
||||||
|
void purple_plugins_add_finddir(directory_which finddir);
|
||||||
|
|
||||||
static guint _purple_glib_input_add(gint fd,
|
static guint _purple_glib_input_add(gint fd,
|
||||||
PurpleInputCondition condition,
|
PurpleInputCondition condition,
|
||||||
PurpleInputFunction function, gpointer data);
|
PurpleInputFunction function, gpointer data);
|
||||||
|
|
|
@ -66,7 +66,7 @@ protocol_count()
|
||||||
const char*
|
const char*
|
||||||
signature()
|
signature()
|
||||||
{
|
{
|
||||||
return "purple";
|
return PURPLE_ADDON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -936,8 +936,7 @@ JabberHandler::_SetupAvatarCache()
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
path.Append("Caya");
|
path.Append("Cardie/Cache/Accounts");
|
||||||
path.Append("Cache");
|
|
||||||
path.Append(GetName());
|
path.Append(GetName());
|
||||||
|
|
||||||
if (create_directory(path.Path(), 0755) != B_OK)
|
if (create_directory(path.Path(), 0755) != B_OK)
|
||||||
|
|
Ŝarĝante…
Reference in New Issue