Load protocols from any system add-on directory
… rather than soley "$APPDIR/protocols/". The vague "protocols/" leaf was also renamed to "cardie/".
This commit is contained in:
parent
ab6988d9ba
commit
ed7fe730cb
|
@ -26,11 +26,12 @@
|
|||
static ProtocolManager* fInstance = NULL;
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
ProtocolManager::Init(BDirectory dir, BHandler* target)
|
||||
{
|
||||
BEntry entry;
|
||||
BPath path;
|
||||
bool ret = false;
|
||||
|
||||
dir.Rewind();
|
||||
|
||||
|
@ -42,10 +43,11 @@ ProtocolManager::Init(BDirectory dir, BHandler* target)
|
|||
if (id < 0)
|
||||
continue;
|
||||
|
||||
// If add-on's API version fits then load accounts...
|
||||
// If add-on's API version fits then load accounts…
|
||||
ChatProtocolAddOn* addOn = new ChatProtocolAddOn(id, path.Path());
|
||||
if (addOn->Version() != APP_VERSION)
|
||||
continue;
|
||||
ret = true;
|
||||
|
||||
// If add-on has multiple protocols, also load them
|
||||
for (int32 i = 0; i < addOn->CountProtocols(); i++) {
|
||||
|
@ -60,6 +62,7 @@ ProtocolManager::Init(BDirectory dir, BHandler* target)
|
|||
delete proto;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,9 +161,8 @@ ProtocolManager::_LoadAccounts(const char* image_path, ChatProtocolAddOn* addOn,
|
|||
BEntry entry;
|
||||
bool firstDone = false;
|
||||
|
||||
while (dir.GetNextEntry(&entry) == B_OK) {
|
||||
_LoadAccount(addOn, entry, target);
|
||||
}
|
||||
while (dir.GetNextEntry(&entry) == B_OK)
|
||||
_LoadAccount(addOn, entry, target);
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,5 +198,3 @@ ProtocolManager::_LoadAccount(ChatProtocolAddOn* addOn, BEntry accountEntry,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class BHandler;
|
|||
|
||||
class ProtocolManager {
|
||||
public:
|
||||
void Init(BDirectory dir, BHandler* target);
|
||||
bool Init(BDirectory dir, BHandler* target);
|
||||
|
||||
static ProtocolManager* Get();
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
/*
|
||||
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
||||
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
|
||||
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Andrea Anzani, andrea.anzani@gmail.com
|
||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
* Jaidyn Levesque, jadedctrl@teknik.io
|
||||
*/
|
||||
|
||||
#include "TheApp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Catalog.h>
|
||||
|
@ -79,16 +82,16 @@ TheApp::ReadyToRun()
|
|||
}
|
||||
printf("Loaded Emoticons settings from: %s\n", currentPath.Path());
|
||||
|
||||
currentPath = appDir;
|
||||
currentPath.Append("protocols");
|
||||
if (BEntry(currentPath.Path()).Exists()) {
|
||||
printf("Looking for protocols from: %s\n", currentPath.Path());
|
||||
bool win = false;
|
||||
if (_LoadProtocols(B_SYSTEM_ADDONS_DIRECTORY)) win = true;
|
||||
if (_LoadProtocols(B_USER_ADDONS_DIRECTORY)) win = true;
|
||||
if (_LoadProtocols(B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY)) win = true;
|
||||
if (_LoadProtocols(B_USER_NONPACKAGED_ADDONS_DIRECTORY)) win = true;
|
||||
if (_LoadProtocols(appDir)) win = true;
|
||||
|
||||
ProtocolManager::Get()->Init(BDirectory(currentPath.Path()),
|
||||
fMainWin);
|
||||
} else {
|
||||
BString msg("Can't find protocols in:\n\n%path%");
|
||||
msg.ReplaceAll("%path%", currentPath.Path());
|
||||
if (win == false) {
|
||||
BString msg(B_TRANSLATE("No protocols found!\nPlease make sure %app% was installed correctly."));
|
||||
msg.ReplaceAll("%app%", APP_NAME);
|
||||
BAlert* alert = new BAlert("", msg.String(), B_TRANSLATE("Ouch!"));
|
||||
alert->Go();
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
|
@ -119,8 +122,8 @@ TheApp::AboutRequested()
|
|||
NULL
|
||||
};
|
||||
|
||||
BString extraInfo(B_TRANSLATE("%app% is released under the GNU GPL "
|
||||
"License.\nSome parts of %app% are available under MIT license.\n"
|
||||
BString extraInfo(B_TRANSLATE("%app% is released under the MIT License.\n"
|
||||
"Add-on and library licenses may vary.\n"
|
||||
"Built: %buildDate%"));
|
||||
extraInfo.ReplaceAll("%buildDate", BUILD_DATE);
|
||||
extraInfo.ReplaceAll("%app%", B_TRANSLATE_SYSTEM_NAME(APP_NAME));
|
||||
|
@ -158,3 +161,25 @@ TheApp::MessageReceived(BMessage* message)
|
|||
BLooper::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TheApp::_LoadProtocols(directory_which finddir)
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(finddir, &path) == B_OK)
|
||||
return _LoadProtocols(path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TheApp::_LoadProtocols(BPath path)
|
||||
{
|
||||
path.Append(BString(APP_NAME).ToLower());
|
||||
if (BEntry(path.Path()).Exists()) {
|
||||
printf("Looking for protocols from: %s\n", path.Path());
|
||||
return ProtocolManager::Get()->Init(BDirectory(path.Path()), fMainWin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
||||
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
|
||||
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _THE_APP_H
|
||||
#define _THE_APP_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <FindDirectory.h>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
|
@ -26,6 +28,9 @@ public:
|
|||
MainWindow* GetMainWindow() const;
|
||||
|
||||
private:
|
||||
bool _LoadProtocols(directory_which finddir);
|
||||
bool _LoadProtocols(BPath path);
|
||||
|
||||
MainWindow* fMainWin;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
## file:///system/develop/documentation/makefile-engine.html
|
||||
|
||||
# The name of the binary.
|
||||
NAME = protocols/irc
|
||||
NAME = cardie/irc
|
||||
|
||||
# The type of binary, must be one of:
|
||||
# APP: Application
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
## file:///system/develop/documentation/makefile-engine.html
|
||||
|
||||
# The name of the binary.
|
||||
NAME = protocols/purple
|
||||
NAME = cardie/purple
|
||||
|
||||
# The type of binary, must be one of:
|
||||
# APP: Application
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
## file:///system/develop/documentation/makefile-engine.html
|
||||
|
||||
# The name of the binary.
|
||||
NAME = protocols/jabber
|
||||
NAME = cardie/jabber
|
||||
|
||||
# The type of binary, must be one of:
|
||||
# APP: Application
|
||||
|
|
Ŝarĝante…
Reference in New Issue