2010-05-07 04:47:10 -05:00
|
|
|
/*
|
2011-12-03 16:38:03 -06:00
|
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
|
|
|
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
|
2010-05-07 04:47:10 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Andrea Anzani, andrea.anzani@gmail.com
|
|
|
|
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
|
|
|
*/
|
|
|
|
|
2021-05-19 16:12:19 -05:00
|
|
|
#include "TheApp.h"
|
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <Alert.h>
|
|
|
|
#include <Path.h>
|
|
|
|
#include <Roster.h>
|
|
|
|
|
2021-05-19 16:12:19 -05:00
|
|
|
#include <librunview/Emoticor.h>
|
|
|
|
|
2010-05-12 13:57:19 -05:00
|
|
|
#include "AboutWindow.h"
|
2021-06-22 01:06:00 -05:00
|
|
|
#include "Cardie.h"
|
2021-06-20 12:44:20 -05:00
|
|
|
#include "AppMessages.h"
|
2010-05-07 04:47:10 -05:00
|
|
|
#include "FilePanel.h"
|
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "ProtocolManager.h"
|
2011-12-14 17:36:27 -06:00
|
|
|
#include "ReplicantStatusView.h"
|
2010-05-16 16:02:50 -05:00
|
|
|
#include "Server.h"
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-06-11 20:33:28 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
TheApp::TheApp()
|
2010-05-19 17:28:26 -05:00
|
|
|
:
|
2021-06-20 12:44:20 -05:00
|
|
|
BApplication(APP_SIGNATURE),
|
2010-05-07 04:47:10 -05:00
|
|
|
fMainWin(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TheApp::ReadyToRun()
|
2011-12-14 17:36:27 -06:00
|
|
|
{
|
2010-05-07 04:47:10 -05:00
|
|
|
app_info theInfo;
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
fMainWin = new MainWindow();
|
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
if (be_app->GetAppInfo(&theInfo) == B_OK) {
|
2010-05-16 16:02:50 -05:00
|
|
|
BPath appDir(&theInfo.ref);
|
|
|
|
appDir.GetParent(&appDir);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
// Emoticons settings
|
|
|
|
BPath currentPath = appDir;
|
2010-05-07 04:47:10 -05:00
|
|
|
currentPath.Append("smileys");
|
|
|
|
currentPath.Append("settings.xml");
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
// Load emoticons
|
2010-05-07 04:47:10 -05:00
|
|
|
BEntry entry(currentPath.Path());
|
|
|
|
if (entry.Exists())
|
|
|
|
Emoticor::Get()->LoadConfig(currentPath.Path());
|
|
|
|
else {
|
|
|
|
BString msg("Can't find smileys settings in:\n\n");
|
|
|
|
msg << currentPath.Path();
|
|
|
|
BAlert* alert = new BAlert("", msg.String(), "Ouch!");
|
2021-06-11 20:33:28 -05:00
|
|
|
// alert->Go();
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
printf("Loaded Emoticons settings from: %s\n", currentPath.Path());
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
currentPath = appDir;
|
2010-05-07 04:47:10 -05:00
|
|
|
currentPath.Append("protocols");
|
|
|
|
if (BEntry(currentPath.Path()).Exists()) {
|
|
|
|
printf("Looking for protocols from: %s\n", currentPath.Path());
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
ProtocolManager::Get()->Init(BDirectory(currentPath.Path()),
|
|
|
|
fMainWin);
|
2010-05-07 04:47:10 -05:00
|
|
|
} else {
|
|
|
|
BString msg("Can't find protocols in:\n\n");
|
|
|
|
msg << currentPath.Path();
|
|
|
|
BAlert* alert = new BAlert("", msg.String(), "Ouch!");
|
|
|
|
alert->Go();
|
|
|
|
PostMessage(B_QUIT_REQUESTED);
|
|
|
|
return;
|
2010-05-16 16:02:50 -05:00
|
|
|
}
|
2010-05-07 04:47:10 -05:00
|
|
|
}
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
fMainWin->Start();
|
2010-05-07 04:47:10 -05:00
|
|
|
fMainWin->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-12 13:57:19 -05:00
|
|
|
void
|
|
|
|
TheApp::AboutRequested()
|
|
|
|
{
|
|
|
|
const char* holders[] = {
|
|
|
|
"2009-2010 Andrea Anzani",
|
2015-06-24 11:45:55 -05:00
|
|
|
"2010-2015 Dario Casalinuovo",
|
2010-05-12 13:57:19 -05:00
|
|
|
"2009-2010 Pier Luigi Fiorini",
|
2021-06-22 01:06:00 -05:00
|
|
|
"2021 Jaidyn Levesque",
|
2010-05-12 13:57:19 -05:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* authors[] = {
|
|
|
|
"Andrea Anzani",
|
2015-06-24 11:45:55 -05:00
|
|
|
"Dario Casalinuovo",
|
2010-05-12 13:57:19 -05:00
|
|
|
"Pier Luigi Fiorini",
|
2021-06-20 12:44:20 -05:00
|
|
|
"Jaidyn Levesque",
|
2010-05-12 13:57:19 -05:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
BString extraInfo;
|
2021-06-22 01:06:00 -05:00
|
|
|
extraInfo << "%app% is released under the GNU GPL License." << "\n";
|
|
|
|
extraInfo << "Some parts of %app% are available under MIT license." << "\n";
|
2010-05-12 13:57:19 -05:00
|
|
|
extraInfo << "Built: " << BUILD_DATE;
|
2021-06-22 01:06:00 -05:00
|
|
|
extraInfo.ReplaceAll("%app%", APP_NAME);
|
2010-05-12 13:57:19 -05:00
|
|
|
|
2021-06-22 01:06:00 -05:00
|
|
|
AboutWindow* about = new AboutWindow(APP_NAME, holders,
|
2010-05-12 13:57:19 -05:00
|
|
|
authors, extraInfo.String());
|
|
|
|
about->Show();
|
2012-05-15 12:20:11 -05:00
|
|
|
delete about;
|
2010-05-12 13:57:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
MainWindow*
|
|
|
|
TheApp::GetMainWindow() const
|
|
|
|
{
|
|
|
|
return fMainWin;
|
|
|
|
}
|
2011-12-14 17:36:27 -06:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TheApp::MessageReceived(BMessage* message)
|
|
|
|
{
|
|
|
|
switch (message->what) {
|
2021-06-20 12:44:20 -05:00
|
|
|
case APP_REPLICANT_STATUS_SET:
|
|
|
|
case APP_REPLICANT_SHOW_WINDOW:
|
|
|
|
case APP_SHOW_SETTINGS:
|
|
|
|
case APP_REPLICANT_MESSENGER:
|
2011-12-14 17:36:27 -06:00
|
|
|
DetachCurrentMessage();
|
|
|
|
fMainWin->PostMessage(message);
|
|
|
|
break;
|
2021-06-20 12:44:20 -05:00
|
|
|
case APP_REPLICANT_EXIT:
|
2011-12-14 17:36:27 -06:00
|
|
|
// TODO BAlert here
|
|
|
|
PostMessage(B_QUIT_REQUESTED);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLooper::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|