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