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)
|
||||
return NULL;
|
||||
|
||||
path.Append(APP_NAME "/Protocols");
|
||||
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);
|
||||
path.Append(APP_NAME "/Accounts");
|
||||
if (create_directory(path.Path(), 0755) != B_OK)
|
||||
return NULL;
|
||||
|
||||
|
@ -147,16 +129,17 @@ AccountPath(const char* signature)
|
|||
const char*
|
||||
AccountPath(const char* signature, const char* subsignature)
|
||||
{
|
||||
if (BString(signature) == BString(subsignature)
|
||||
|| BString(subsignature).IsEmpty() == true)
|
||||
return AccountPath(signature);
|
||||
|
||||
BPath path(AccountPath(signature));
|
||||
|
||||
path.Append(subsignature);
|
||||
if (create_directory(path.Path(), 0755) != B_OK)
|
||||
BPath path(AccountsPath());
|
||||
if (path.InitCheck() != B_OK)
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -178,6 +161,7 @@ const char*
|
|||
AccountCachePath(const char* accountName)
|
||||
{
|
||||
BPath path(CachePath());
|
||||
path.Append("Accounts");
|
||||
if (path.InitCheck() != B_OK)
|
||||
return NULL;
|
||||
path.Append(accountName);
|
||||
|
|
|
@ -31,7 +31,6 @@ BMenu* CreateAccountMenu(AccountInstances accounts, BMessage msg,
|
|||
BMessage* allMsg = NULL);
|
||||
|
||||
const char* AccountsPath();
|
||||
const char* AccountPath(const char* signature);
|
||||
const char* AccountPath(const char* signature, const char* subsignature);
|
||||
|
||||
const char* CachePath();
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
#define _PURPLE_H
|
||||
|
||||
#define PURPLE_SIGNATURE "application/x-vnd.cardie.purple"
|
||||
#define PURPLE_ADDON "purple"
|
||||
|
||||
#endif // _PURPLE_H
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
#include <libpurple/purple.h>
|
||||
#include <libpurple/status.h>
|
||||
|
||||
#include <Directory.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Path.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include <Cardie.h>
|
||||
|
@ -85,7 +87,6 @@ PurpleApp::MessageReceived(BMessage* msg)
|
|||
protocolInfo.AddString("name", info->name);
|
||||
protocolInfo.AddString("id", info->id);
|
||||
SendMessage(thread_id, protocolInfo);
|
||||
|
||||
break;
|
||||
}
|
||||
case PURPLE_CONNECT_ACCOUNT:
|
||||
|
@ -495,6 +496,14 @@ init_libpurple()
|
|||
{
|
||||
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))
|
||||
return B_ERROR;
|
||||
|
||||
|
@ -643,7 +652,6 @@ signal_sent_im_msg(PurpleAccount* account, const char* receiver,
|
|||
sent.AddString("chat_id", receiver);
|
||||
sent.AddString("user_id", purple_account_get_username(account));
|
||||
sent.AddString("body", message);
|
||||
sent.PrintToStream();
|
||||
((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,
|
||||
PurpleInputFunction function, gpointer data)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <libpurple/purple.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <ObjectList.h>
|
||||
#include <StringList.h>
|
||||
|
||||
|
@ -128,6 +129,9 @@ private:
|
|||
PurpleStatusPrimitive cardie_status_to_purple(UserStatus 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,
|
||||
PurpleInputCondition condition,
|
||||
PurpleInputFunction function, gpointer data);
|
||||
|
|
|
@ -66,7 +66,7 @@ protocol_count()
|
|||
const char*
|
||||
signature()
|
||||
{
|
||||
return "purple";
|
||||
return PURPLE_ADDON;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -936,8 +936,7 @@ JabberHandler::_SetupAvatarCache()
|
|||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
path.Append("Caya");
|
||||
path.Append("Cache");
|
||||
path.Append("Cardie/Cache/Accounts");
|
||||
path.Append(GetName());
|
||||
|
||||
if (create_directory(path.Path(), 0755) != B_OK)
|
||||
|
|
Ŝarĝante…
Reference in New Issue