|
From: <ane...@us...> - 2013-06-05 00:25:26
|
Revision: 944
http://sourceforge.net/p/vision/code/944
Author: anevilyak
Date: 2013-06-05 00:25:23 +0000 (Wed, 05 Jun 2013)
Log Message:
-----------
Change how settings are loaded.
- If the main settings file has not yet been created, we now look for
InitialSettings in the app directory, and use that as a starting point.
Modified Paths:
--------------
branches/0.9.7/src/Vision.cpp
branches/0.9.7/src/Vision.h
Modified: branches/0.9.7/src/Vision.cpp
===================================================================
--- branches/0.9.7/src/Vision.cpp 2013-06-04 23:48:57 UTC (rev 943)
+++ branches/0.9.7/src/Vision.cpp 2013-06-05 00:25:23 UTC (rev 944)
@@ -1,21 +1,21 @@
-/*
- * The contents of this file are subject to the Mozilla Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
+/*
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
* The Original Code is Vision.
- *
+ *
* The Initial Developer of the Original Code is The Vision Team.
* Portions created by The Vision Team are
* Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights
* Reserved.
- *
+ *
* Contributor(s): Wade Majors <wa...@ez...>
* Rene Gollent
* Todd Lair
@@ -115,7 +115,7 @@
fStartupTime = system_time();
app_info info;
- if (GetAppInfo(&info) == B_OK) fAppRef = info.ref;
+ if (GetAppInfo(&info) == B_OK) fAppRef = info.ref;
URLCrunch::UpdateTagList();
}
@@ -156,7 +156,7 @@
break;
}
}
-
+
if (fDebugShutdown)
{
buffer += "thread: ";
@@ -170,27 +170,27 @@
case B_THREAD_RUNNING:
buffer += "running\n";
break;
-
+
case B_THREAD_READY:
buffer += "ready\n";
break;
-
+
case B_THREAD_RECEIVING:
buffer += "receiving\n";
break;
-
+
case B_THREAD_ASLEEP:
buffer += "asleep\n";
break;
-
+
case B_THREAD_SUSPENDED:
buffer += "suspended\n";
break;
-
+
case B_THREAD_WAITING:
buffer += "waiting\n";
break;
-
+
default:
buffer += "???\n";
}
@@ -214,7 +214,7 @@
#endif
}
- return t_count;
+ return t_count;
}
void
@@ -314,7 +314,7 @@
fColors[C_NOTIFY_OFF] = myBlack;
fColors[C_NOTIFYLIST_BACKGROUND] = WINLIST_BG_COLOR;
fColors[C_NOTIFYLIST_SELECTION] = WINLIST_SEL_COLOR;
-
+
fClientFont[F_TEXT] = new BFont (be_plain_font);
fClientFont[F_SERVER] = new BFont (be_plain_font);
fClientFont[F_URL] = new BFont (be_plain_font);
@@ -323,7 +323,7 @@
fClientFont[F_WINLIST] = new BFont (be_plain_font);
fClientFont[F_LISTAGENT] = new BFont (be_plain_font);
fClientFont[F_TIMESTAMP] = new BFont (be_plain_font);
-
+
fEvents[E_JOIN] = "*** $N ($I@$A) has joined the channel.";
fEvents[E_PART] = "*** $N has left the channel.";
fEvents[E_NICK] = "*** $N is now known as $n.";
@@ -347,7 +347,7 @@
fCommands[CMD_UPTIME] = "OS Uptime [BeOS]: $U";
#endif
uint32 i = 0;
-
+
for( const char* eventName = kSoundEventNames[i]; eventName != NULL; i++,
eventName = kSoundEventNames[i] )
add_system_beep_event(eventName);
@@ -358,7 +358,7 @@
{
// initialize arrays with Vision's default settings in case of new user
InitDefaults();
-
+
Theme::TimestampFore = C_TIMESTAMP;
Theme::TimestampBack = C_TIMESTAMP;
Theme::TimespaceFore = MAX_COLORS;
@@ -369,12 +369,12 @@
Theme::NormalBack = C_TEXT;
Theme::NormalFont = F_TEXT;
Theme::SelectionBack = C_SELECTION;
-
+
if (fDebugSettings)
printf (":SETTINGS: loading...\n");
-
+
fVisionSettings = new SettingsFile ("VisionSettings", "Vision");
-
+
if (fVisionSettings->InitCheck() == B_OK)
{
fVisionSettings->Load();
@@ -382,10 +382,15 @@
else
printf(":ERROR: Error Loading /Vision/VisionSettings\n");
+ if (fVisionSettings->IsEmpty())
+ {
+ LoadInitialSettings();
+ }
+
LoadAliases();
int32 i (0);
-
+
LoadDefaults (SET_SERVER);
LoadDefaults (SET_GENERAL);
LoadDefaults (SET_WINDOW);
@@ -394,11 +399,11 @@
LoadDefaults (SET_COLOR);
LoadDefaults (SET_STRINGS);
LoadDefaults (SET_DCC);
-
+
// initialize theme, TODO: move to separate function
-
+
fActiveTheme->WriteLock();
-
+
for (i = 0; i < MAX_COLORS; i++)
{
fActiveTheme->SetForeground (i, fColors[i]);
@@ -406,8 +411,8 @@
}
for (i = C_MIRC_WHITE; i < MAX_COLORS; i++)
fActiveTheme->SetBackground (i, fColors[i]);
-
- fActiveTheme->SetBackground (C_SELECTION, fColors [C_SELECTION]);
+
+ fActiveTheme->SetBackground (C_SELECTION, fColors [C_SELECTION]);
fActiveTheme->SetBackground (C_TIMESTAMP, fColors[C_TIMESTAMP_BACKGROUND]);
fActiveTheme->SetBackground (MAX_COLORS, fColors[C_BACKGROUND]);
fActiveTheme->SetForeground (MAX_COLORS, fColors[C_TEXT]);
@@ -418,7 +423,7 @@
fActiveTheme->WriteUnlock();
- fSettingsLoaded = true;
+ fSettingsLoaded = true;
if (fDebugSettings)
printf (":SETTINGS: done loading\n");
}
@@ -427,12 +432,12 @@
VisionApp::SaveSettings (void)
{
BAutolock saveLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!saveLock.IsLocked())
return false;
- SaveAliases();
-
+ SaveAliases();
+
if ((fVisionSettings->Save() == B_OK) && fDebugSettings)
{
printf (":SETTINGS: saved to file\n");
@@ -442,6 +447,35 @@
}
void
+VisionApp::LoadInitialSettings (void)
+{
+ image_info info;
+ int32 cookie = 0;
+ while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK)
+ {
+ if (info.type == B_APP_IMAGE)
+ {
+ BPath path(info.name);
+ if (path.InitCheck() != B_OK)
+ return;
+
+ path.GetParent(&path);
+ path.Append("InitialSettings");
+ BFile file(path.Path(), B_READ_ONLY);
+ if (file.InitCheck() != B_OK)
+ return;
+
+ BMessage message;
+ if (message.Unflatten(&file) != B_OK)
+ return;
+
+ fVisionSettings->Append(message);
+ break;
+ }
+ }
+}
+
+void
VisionApp::LoadDefaults (int32 section)
{
// sets defaults for various states in vision
@@ -462,7 +496,7 @@
}
}
break;
-
+
case SET_GENERAL:
{
if (!fVisionSettings->HasBool ("versionParanoid"))
@@ -470,36 +504,36 @@
if (!fVisionSettings->HasBool ("timestamp"))
fVisionSettings->AddBool ("timestamp", false);
-
+
if (!fVisionSettings->HasString ("timestamp_format"))
fVisionSettings->AddString ("timestamp_format", "[%H:%M]");
-
+
if (!fVisionSettings->HasBool ("log_enabled"))
fVisionSettings->AddBool ("log_enabled", false);
if (!fVisionSettings->HasBool ("log_filetimestamp"))
fVisionSettings->AddBool ("log_filetimestamp", false);
-
+
if (!fVisionSettings->HasBool ("stripcolors"))
fVisionSettings->AddBool ("stripcolors", true);
-
+
if (!fVisionSettings->HasBool ("Newbie Spam Mode"))
fVisionSettings->AddBool("Newbie Spam Mode", true);
-
+
if (!fVisionSettings->HasBool ("queryOnMsg"))
fVisionSettings->AddBool ("queryOnMsg", false);
-
+
if (!fVisionSettings->HasBool ("notifyExpanded"))
fVisionSettings->AddBool("notifyExpanded", true);
-
+
if (!fVisionSettings->HasString ("logBaseDir"))
fVisionSettings->AddString("logBaseDir", "logs");
-
+
if (!fVisionSettings->HasInt32 ("encoding"))
fVisionSettings->AddInt32("encoding", B_ISO1_CONVERSION);
}
break;
-
+
case SET_WINDOW:
{
if (!fVisionSettings->HasBool ("catchAltW"))
@@ -507,16 +541,16 @@
if (!fVisionSettings->HasRect ("clientWinRect"))
fVisionSettings->AddRect ("clientWinRect", BRect (100, 100, 600, 460));
-
+
if (!fVisionSettings->HasRect ("windowDockRect"))
fVisionSettings->AddRect ("windowDockRect", BRect (0, 0, 0, 0));
-
+
if (!fVisionSettings->HasRect ("NetPrefWinRect"))
fVisionSettings->AddRect ("NetPrefWinRect", BRect (0, 0, 0, 0));
-
+
if (!fVisionSettings->HasRect ("namesListRect"))
fVisionSettings->AddRect ("namesListRect", BRect (0, 0, 100, 0));
-
+
if (!fVisionSettings->HasRect ("GenPrefWinRect"))
fVisionSettings->AddRect ("GenPrefWinRect", BRect (0,0,0,0));
}
@@ -528,7 +562,7 @@
fVisionSettings->AddString ("alsoKnownAs", "-9y99");
}
break;
-
+
case SET_FONT:
{
font_family default_family;
@@ -537,7 +571,7 @@
be_plain_font->GetFamilyAndStyle (&default_family, &default_style);
size = be_plain_font->Size();
int32 i (0);
-
+
for (i = 0; i < MAX_FONTS; i++)
{
BString fontStr, styleStr;
@@ -556,18 +590,18 @@
BString family;
BString style;
size = 0.0;
-
+
fVisionSettings->FindString (fontStr.String(), &family);
fVisionSettings->FindString (styleStr.String(), &style);
fVisionSettings->FindFloat ("size", i, &size);
-
+
ClientFontFamilyAndStyle (i, family.String(), style.String());
- ClientFontSize (i, size);
+ ClientFontSize (i, size);
}
}
}
break;
-
+
case SET_COLOR:
{
// load defaults from color array into settings file
@@ -585,7 +619,7 @@
}
}
break;
-
+
case SET_STRINGS:
{
BString eventStr, commandStr;
@@ -599,7 +633,7 @@
else
fVisionSettings->FindString (eventStr.String(), &fEvents[i]);
}
-
+
// fCommands
for (i = 0; i < MAX_COMMANDS; i++)
{
@@ -612,7 +646,7 @@
}
}
break;
-
+
case SET_DCC:
{
if (!fVisionSettings->HasString ("dccDefPath"))
@@ -628,7 +662,7 @@
if (!fVisionSettings->HasString ("dccMaxPort"))
fVisionSettings->AddString ("dccMaxPort", "45000");
}
- break;
+ break;
}
}
@@ -639,20 +673,20 @@
if (fIdentSocket >= 0)
close (fIdentSocket);
-
+
BMessenger msgr(fClientWin);
if (msgr.IsValid())
msgr.SendMessage(B_QUIT_REQUESTED);
-
+
if (fSetupWin)
BMessenger(fSetupWin).SendMessage(B_QUIT_REQUESTED);
-
+
if (fPrefsWin)
BMessenger(fPrefsWin).SendMessage(B_QUIT_REQUESTED);
if (fNetWin)
BMessenger(fPrefsWin).SendMessage(B_QUIT_REQUESTED);
-
+
// give our child threads a chance to die gracefully
while (ThreadStates() > 2)
snooze (100000);
@@ -688,7 +722,7 @@
{
for (int32 i = 1; i < ac; ++i)
{
-
+
if (strcmp (av[i], "-!") == 0)
{
fDebugRecv = true;
@@ -697,25 +731,25 @@
fNumBench = true;
fDebugShutdown = true;
}
-
+
else if (strcmp (av[i], "-r") == 0)
fDebugRecv = true;
else if (strcmp (av[i], "-s") == 0)
fDebugSend = true;
-
+
else if (strcmp (av[i], "-S") == 0)
fDebugSettings = true;
-
+
else if (strcmp (av[i], "-u") == 0)
fDebugShutdown = true;
-
+
else if (strcmp (av[i], "-n") == 0)
fNumBench = true;
-
+
else if (strcmp (av[i], "-a") == 0)
fDisableAutostart = true;
-
+
else if (strcmp (av[i], "-T") == 0)
{
#if 0
@@ -725,7 +759,7 @@
if (IsLaunching())
Quit();
}
-
+
else if (strcmp (av[i], "--help") == 0)
{
printf ("Vision command line switches:\n");
@@ -742,7 +776,7 @@
if (IsLaunching())
Quit();
}
-
+
}
}
@@ -784,13 +818,13 @@
{
const ServerData *data (NULL);
int32 size;
- for (int32 i = 0; netData.FindData ("server", B_RAW_TYPE, i,
+ for (int32 i = 0; netData.FindData ("server", B_RAW_TYPE, i,
reinterpret_cast<const void **>(&data), &size) == B_OK; i++)
{
// look for a primary server
if (data->state == SERVER_PRIMARY)
return true;
- }
+ }
}
return false;
}
@@ -805,7 +839,7 @@
resume_thread (fIdentThread);
if (!CheckStartupNetworks())
- {
+ {
fSetupWin = new SetupWindow ();
fSetupWin->Show();
}
@@ -829,13 +863,13 @@
if (argument.IFindFirst ("www") == 0)
argument.Prepend ("http://");
-
+
else if (argument.IFindFirst ("ftp") == 0)
argument.Prepend ("ftp://");
}
const char *args[] = { argument.String(), 0 };
-
+
if (argument.IFindFirst ("file:") == 0)
{
// The URL is guaranteed to be at least "file:/"
@@ -870,9 +904,9 @@
fAboutWin = 0;
if (fShuttingDown)
PostMessage (B_QUIT_REQUESTED);
- }
+ }
break;
-
+
case M_SETUP_SHOW:
{
if (fSetupWin)
@@ -893,7 +927,7 @@
PostMessage (B_QUIT_REQUESTED);
}
break;
-
+
case M_PREFS_SHOW:
{
if (fPrefsWin)
@@ -903,16 +937,16 @@
fPrefsWin = new PrefsWindow();
fPrefsWin->Show();
}
- }
+ }
break;
-
+
case M_PREFS_CLOSE:
{
SaveSettings();
fPrefsWin = 0;
}
break;
-
+
case M_NETWORK_SHOW:
{
if (fNetWin)
@@ -921,9 +955,9 @@
{
fNetWin = new NetworkWindow();
fNetWin->Show();
-
+
}
- }
+ }
break;
case M_NETWORK_CLOSE:
@@ -932,7 +966,7 @@
fNetWin = 0;
}
break;
-
+
case M_CONNECT_NETWORK:
{
BRect clientWinRect (GetRect("clientWinRect"));
@@ -970,7 +1004,7 @@
{
if (fClientWin == NULL)
break;
-
+
fClientWin->PostMessage (msg);
}
break;
@@ -984,14 +1018,14 @@
else
{
DCCConnect *view;
-
+
msg->FindPointer ("view", reinterpret_cast<void **>(&view));
fDccFileWin = new DCCFileWindow (view);
fDccFileWin->Show();
}
}
break;
-
+
case M_DCC_MESSENGER:
if (msg->IsSourceWaiting())
{
@@ -1013,7 +1047,7 @@
Broadcast(msg);
}
break;
-
+
case M_LOAD_URL:
{
BString url (msg->FindString("url"));
@@ -1023,7 +1057,7 @@
}
}
break;
-
+
default:
BApplication::MessageReceived (msg);
}
@@ -1058,7 +1092,7 @@
case VERSION_VERSION:
result = VERSION_STRING;
break;
-
+
case VERSION_DATE:
result = BUILD_DATE;
result.ReplaceAll ("_", " ");
@@ -1066,7 +1100,7 @@
}
}
-const char *
+const char *
VisionApp::GetString (const char *stringName) const
{
BAutolock stringLock (const_cast<BLocker *>(&fSettingsLock));
@@ -1077,14 +1111,14 @@
{
if (fDebugSettings)
printf (":SETTINGS: looking up String \"%s\"... ", stringName);
-
+
if ((fVisionSettings->FindString (stringName, &value)) == B_OK)
- if (fDebugSettings)
+ if (fDebugSettings)
printf ("found; returning %s\n", value);
else
if (fDebugSettings)
printf (" not found; returning NULL\n");
- }
+ }
return value;
}
@@ -1093,7 +1127,7 @@
VisionApp::SetString (const char *stringName, int32 index, const char *value)
{
BAutolock stringLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!stringLock.IsLocked())
return;
@@ -1104,10 +1138,10 @@
msg.AddString ("which", stringName);
Broadcast (&msg);
}
-
+
BString tmp;
tmp = value;
-
+
fVisionSettings->ReplaceString (stringName, index, tmp);
}
@@ -1117,13 +1151,13 @@
BRect rect (0.0, 0.0, 0.0, 0.0);
BAutolock rectLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!rectLock.IsLocked())
return rect;
-
+
if (fVisionSettings->HasRect (settingName))
fVisionSettings->FindRect (settingName, &rect);
-
+
return rect;
}
@@ -1131,10 +1165,10 @@
VisionApp::SetRect (const char *settingName, BRect value)
{
BAutolock rectLock(const_cast<BLocker *>(&fSettingsLock));
-
+
if (!rectLock.IsLocked())
return;
-
+
fVisionSettings->ReplaceRect (settingName, value);
}
@@ -1145,11 +1179,11 @@
rgb_color color = {0, 0, 0, 255};
BAutolock colorLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!colorLock.IsLocked())
return color;
-
-
+
+
if (which < MAX_COLORS && which >= 0)
color = fColors[which];
@@ -1162,10 +1196,10 @@
{
BAutolock colorLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!colorLock.IsLocked())
return;
-
+
if (which < MAX_COLORS && which >= 0
&& (fColors[which].red != color.red
|| fColors[which].green != color.green
@@ -1175,7 +1209,7 @@
fColors[which] = color;
fVisionSettings->ReplaceData ("color", B_RGB_COLOR_TYPE, which,
reinterpret_cast<void * const *>(&color), sizeof(rgb_color));
- fActiveTheme->WriteLock();
+ fActiveTheme->WriteLock();
if (which == C_BACKGROUND)
{
// update regular background color on all other text
@@ -1183,7 +1217,7 @@
fActiveTheme->SetBackground (i , color);
fActiveTheme->SetBackground (MAX_COLORS, color);
}
-
+
// update timestamp bg color
else if (which == C_TIMESTAMP_BACKGROUND)
fActiveTheme->SetBackground (C_TIMESTAMP, color);
@@ -1197,7 +1231,7 @@
}
else
fActiveTheme->SetForeground (which, color);
- fActiveTheme->WriteUnlock();
+ fActiveTheme->WriteUnlock();
}
}
@@ -1211,10 +1245,10 @@
{
BAutolock fontLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!fontLock.IsLocked())
return;
-
+
if (which < MAX_FONTS && which >= 0)
{
BString fontStr;
@@ -1230,7 +1264,7 @@
if (which == F_TEXT)
fActiveTheme->SetFont (MAX_FONTS, fClientFont[which]);
fActiveTheme->WriteUnlock();
-
+
SetString (fontStr.String(), 0, family);
SetString (styleStr.String(), 0, style);
}
@@ -1241,18 +1275,18 @@
VisionApp::ClientFontSize (int32 which, float size)
{
BAutolock fontLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!fontLock.IsLocked())
return;
if (which < MAX_FONTS && which >= 0)
{
fClientFont[which]->SetSize (size);
-
+
fActiveTheme->WriteLock();
fActiveTheme->SetFont (which, fClientFont[which]);
fActiveTheme->WriteUnlock();
-
+
if (fVisionSettings->ReplaceFloat ("size", which, size) != B_OK)
printf("error, could not set font size\n");
}
@@ -1262,11 +1296,11 @@
VisionApp::GetClientFont (int32 which) const
{
BAutolock fontLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!fontLock.IsLocked())
return NULL;
- return which < MAX_FONTS && which >= 0
+ return which < MAX_FONTS && which >= 0
? fClientFont[which] : be_plain_font;
}
/// end font prefs ///
@@ -1276,9 +1310,9 @@
VisionApp::GetEvent (int32 which) const
{
BAutolock eventLock (const_cast<BLocker *>(&fSettingsLock));
-
+
BString value;
-
+
if (eventLock.IsLocked())
{
if (which < MAX_EVENTS && which >= 0)
@@ -1294,7 +1328,7 @@
VisionApp::SetEvent (int32 which, const char *event)
{
BAutolock eventLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!eventLock.IsLocked())
return;
@@ -1316,9 +1350,9 @@
VisionApp::GetCommand (int32 which)
{
BAutolock commandLock (const_cast<BLocker *>(&fSettingsLock));
-
+
BString value;
-
+
if (commandLock.IsLocked())
{
if (which < MAX_COMMANDS && which >= 0)
@@ -1334,7 +1368,7 @@
VisionApp::SetCommand (int32 which, const char *command)
{
BAutolock commandLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!commandLock.IsLocked())
return;
@@ -1345,7 +1379,7 @@
if (which < MAX_COMMANDS && which >= 0)
{
fCommands[which] = command;
-
+
SetString (commandStr.String(), 0, command);
}
}
@@ -1355,22 +1389,22 @@
VisionApp::GetBool (const char *settingName)
{
BAutolock boolLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!boolLock.IsLocked())
return B_ERROR;
if (fDebugSettings)
printf (":SETTINGS: looking up bool \"%s\"... ", settingName);
-
+
bool value (false);
-
+
if (fVisionSettings->FindBool (settingName, &value) == B_OK)
if (fDebugSettings)
printf ("found; returning %s\n", (value)? "true" : "false");
else
if (fDebugSettings)
printf (" not found; returning false\n");
-
+
return value;
}
@@ -1379,12 +1413,12 @@
VisionApp::SetBool (const char *settingName, bool value)
{
BAutolock boolLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!boolLock.IsLocked())
return B_ERROR;
-
+
status_t result (B_OK);
-
+
if ((result = fVisionSettings->ReplaceBool (settingName, value)) == B_OK)
{
BMessage msg (M_STATE_CHANGE);
@@ -1399,10 +1433,10 @@
VisionApp::GetInt32 (const char *settingName)
{
BAutolock intLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (!intLock.IsLocked())
return B_ERROR;
-
+
return fVisionSettings->FindInt32(settingName);
}
@@ -1413,9 +1447,9 @@
if (!intLock.IsLocked())
return B_ERROR;
-
+
status_t result = fVisionSettings->ReplaceInt32 (settingName, value);
-
+
return result;
}
@@ -1425,7 +1459,7 @@
BMessage msg (VIS_NETWORK_DATA);
BAutolock netLock (const_cast<BLocker *>(&fSettingsLock));
-
+
if (netLock.IsLocked())
{
if (!strcmp (network, "defaults"))
@@ -1470,7 +1504,7 @@
if (!netLock.IsLocked())
return B_ERROR;
-
+
if (!strcmp (network, "defaults"))
{
fVisionSettings->ReplaceMessage ("defaults", data);
@@ -1536,7 +1570,7 @@
static const char *tnames[] = {
/* 0 */ "gummi_bear_orgy",
/* 1 */ "complimentary_tote_bag",
- /* 2 */ "cheating_at_solitaire",
+ /* 2 */ "cheating_at_solitaire",
/* 3 */ "impatient",
/* 4 */ "personal_info_uploader",
/* 5 */ "keystroke_logger",
@@ -1557,7 +1591,7 @@
/* 20 */ "peer_reset_thread",
/* 21 */ "chocoak_is_my_hero",
/* 22 */ "blossom", // commander and the leader
- /* 23 */ "bubbles", // the joy and the laughter
+ /* 23 */ "bubbles", // the joy and the laughter
/* 24 */ "buttercup", // shes the toughest fighter
// Powerpuffs save the day!
/* 25 */ "youlooklikeyouneedamonkey",
@@ -1590,20 +1624,20 @@
/* 52 */ "daydreaming",
/* 53 */ "BEWARE OF THE DUCK!" // this one's for you freston :-)
};
-
+
int rnd (rand() % 54);
-
+
switch (thread_type)
{
case THREAD_S:
output = "s>";
break;
-
+
case THREAD_L:
output = "l>";
break;
}
-
+
output += tnames[rnd];
}
@@ -1616,7 +1650,7 @@
int32 bench0;
bench0 = fBench2 - fBench1;
bench0 = bench0 / 100;
-
+
printf ("%s: 0.%04lds\n", ts, bench0);
}
@@ -1651,28 +1685,28 @@
// Unlock();
}
-int32
-VisionApp::Identity (void *)
+int32
+VisionApp::Identity (void *)
{
int32 identSock (0), accepted (0);
- BString ident;
+ BString ident;
char received[64];
-
+
struct sockaddr_in localAddr;
localAddr.sin_family = AF_INET;
localAddr.sin_port = htons (113);
localAddr.sin_addr.s_addr = INADDR_ANY;
-
- if ((identSock = socket (AF_INET, SOCK_STREAM, 0)) >= 0
- && bind (identSock, (struct sockaddr *)&localAddr, sizeof (localAddr)) == 0)
+
+ if ((identSock = socket (AF_INET, SOCK_STREAM, 0)) >= 0
+ && bind (identSock, (struct sockaddr *)&localAddr, sizeof (localAddr)) == 0)
{
vision_app->fIdentSocket = identSock;
- struct linger lng = { 0, 0 };
+ struct linger lng = { 0, 0 };
setsockopt (identSock, SOL_SOCKET, SO_LINGER, &lng, sizeof (linger));
listen (identSock, 1);
- while (!vision_app->fShuttingDown)
+ while (!vision_app->fShuttingDown)
{
struct fd_set rset, eset;
struct sockaddr_in remoteSock;
@@ -1692,11 +1726,11 @@
{
FD_ZERO (&rset);
FD_ZERO (&eset);
-
+
BString remoteIP (inet_ntoa (remoteSock.sin_addr));
ident = vision_app->GetIdent (remoteIP.String());
- if (ident.Length() > 0)
+ if (ident.Length() > 0)
{
memset (received, 0, 64);
FD_SET (accepted, &rset);
@@ -1704,30 +1738,30 @@
if (select (accepted + 1, &rset, 0, &eset, &tv) > 0
&& FD_ISSET (accepted, &rset) && !FD_ISSET (accepted, &eset))
{
-
+
recv (accepted, received, 64, 0);
- int32 len (0);
-
- received[63] = 0;
- while ((len = strlen (received))
- && isspace (received[len - 1]))
+ int32 len (0);
+
+ received[63] = 0;
+ while ((len = strlen (received))
+ && isspace (received[len - 1]))
received[len - 1] = 0;
-
- BString string;
-
- string.Append (received);
- string.Append (" : USERID : BeOS : ");
- string.Append (ident);
- string.Append ("\r\n");
-
- send (accepted, string.String(), string.Length(), 0);
+
+ BString string;
+
+ string.Append (received);
+ string.Append (" : USERID : BeOS : ");
+ string.Append (ident);
+ string.Append ("\r\n");
+
+ send (accepted, string.String(), string.Length(), 0);
}
- }
- else
- {
+ }
+ else
+ {
BString string ("0 , 0 : UNKNOWN : UNKNOWN-ERROR");
send (accepted, string.String(), string.Length(), 0);
- }
+ }
close (accepted);
}
}
@@ -1735,35 +1769,35 @@
}
close (identSock);
- return 0;
-}
-
-void
-VisionApp::AddIdent (const char *server, const char *serverIdent)
-{
- fIdentLock.Lock();
- fIdents.AddString (server, serverIdent);
+ return 0;
+}
+
+void
+VisionApp::AddIdent (const char *server, const char *serverIdent)
+{
+ fIdentLock.Lock();
+ fIdents.AddString (server, serverIdent);
fIdentLock.Unlock();
-}
-
-void
-VisionApp::RemoveIdent (const char *server)
-{
- fIdentLock.Lock();
- fIdents.RemoveName (server);
- fIdentLock.Unlock();
-}
-
-BString
+}
+
+void
+VisionApp::RemoveIdent (const char *server)
+{
+ fIdentLock.Lock();
+ fIdents.RemoveName (server);
+ fIdentLock.Unlock();
+}
+
+BString
VisionApp::GetIdent (const char *server)
{
BString ident;
- fIdentLock.Lock();
- if (fIdents.HasString (server))
- ident = fIdents.FindString (server);
+ fIdentLock.Lock();
+ if (fIdents.HasString (server))
+ ident = fIdents.FindString (server);
fIdentLock.Unlock();
-
- return ident;
+
+ return ident;
}
void
@@ -1773,10 +1807,10 @@
BMessage netMsg (GetNetwork (network));
if (!netMsg.HasString("name"))
return;
-
+
type_code type;
int32 attrCount;
-
+
// make sure this nick hasn't already been added
netMsg.GetInfo ("notify", &type, &attrCount);
for (int32 i = 0; i < attrCount; i++)
@@ -1806,7 +1840,7 @@
}
}
if (i < attrCount)
- SetNetwork (network, &netMsg);
+ SetNetwork (network, &netMsg);
}
void
@@ -1816,7 +1850,7 @@
BMessage netMsg (GetNetwork (network));
if (!netMsg.HasString("name"))
return;
-
+
char optype[8];
memset(optype, 0, sizeof(optype));
if (exclude)
@@ -1827,10 +1861,10 @@
{
strcpy(optype, "ignore");
}
-
+
type_code type;
int32 attrCount;
-
+
// make sure this nick hasn't already been added
netMsg.GetInfo (optype, &type, &attrCount);
for (int32 i = 0; i < attrCount; i++)
@@ -1871,7 +1905,7 @@
}
}
if (i < attrCount)
- SetNetwork (network, &netMsg);
+ SetNetwork (network, &netMsg);
}
@@ -1905,12 +1939,12 @@
BString command(GetWord(cmd, 1).ToUpper());
BString newcmd = fAliases[command];
const char *parse = newcmd.String();
-
+
int32 replidx (0);
int32 varidx (0);
newcmd.ReplaceAll("$C", channel.String());
-
+
while (*parse != '\0')
{
if (*parse != '$')
@@ -1954,7 +1988,7 @@
{
result = B_ERROR;
}
-
+
return result;
}
Modified: branches/0.9.7/src/Vision.h
===================================================================
--- branches/0.9.7/src/Vision.h 2013-06-04 23:48:57 UTC (rev 943)
+++ branches/0.9.7/src/Vision.h 2013-06-05 00:25:23 UTC (rev 944)
@@ -1,21 +1,21 @@
-/*
- * The contents of this file are subject to the Mozilla Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * The Original Code is Vision.
- *
+/*
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is Vision.
+ *
* The Initial Developer of the Original Code is The Vision Team.
* Portions created by The Vision Team are
* Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights
* Reserved.
- *
+ *
* Contributor(s): Wade Majors <wa...@ez...>
* Rene Gollent
* Todd Lair
@@ -61,26 +61,28 @@
virtual bool QuitRequested (void);
virtual void ArgvReceived (int32, char **);
virtual void ReadyToRun (void);
-
+
void LoadURL (const char *);
void VisionVersion (int, BString &);
-
+
+ void LoadInitialSettings (void);
+
void InitDefaults (void);
-
+
void LoadDefaults (int32);
void ClientFontFamilyAndStyle (int32, const char *,
const char *);
void ClientFontSize (int32, float);
const BFont *GetClientFont (int32) const;
-
+
const BRect GetRect (const char *);
void SetRect (const char *, BRect);
-
- const char *GetString (const char *) const;
- void SetString (const char *, int32 index, const char *);
-
+
+ const char *GetString (const char *) const;
+ void SetString (const char *, int32 index, const char *);
+
rgb_color GetColor (int32) const;
void SetColor (int32, const rgb_color);
@@ -92,10 +94,10 @@
bool GetBool (const char *);
status_t SetBool (const char *, bool);
-
+
int32 GetInt32 (const char *);
status_t SetInt32 (const char *, int32);
-
+
BMessage GetNetwork (const char *);
BMessage GetNetwork (int32);
status_t SetNetwork (const char *, BMessage *);
@@ -103,41 +105,41 @@
bool CheckNetworkValid (const char *);
Theme * ActiveTheme(void);
-
+
void GetThreadName (int, BString &);
-
+
void BenchOut (const char *);
void Broadcast (BMessage *);
void Broadcast (BMessage *, const char *, bool = false);
-
+
void AddIdent (const char *, const char *);
void RemoveIdent (const char *);
BString GetIdent (const char *);
static int32 Identity (void *);
-
+
void AddNotifyNick(const char *, const char *);
void RemoveNotifyNick (const char *, const char *);
void AddIgnoreNick(const char *, const char *, bool = false);
void RemoveIgnoreNick (const char *, const char *, bool = false);
-
+
void AcquireDCCLock (void);
void ReleaseDCCLock (void);
bool SaveSettings (void);
-
+
bigtime_t VisionUptime (void);
-
+
bool HasAlias(const BString &) const;
BString ParseAlias(const char *, const BString &);
status_t AddAlias(const BString &, const BString &);
void RemoveAlias(const BString &);
void LoadAliases();
void SaveAliases();
-
+
int32 CountAliases() const;
bool GetNextAlias(void **, BString &, BString &);
-
+
BString fEvents[MAX_EVENTS];
bool fDebugSettings;
@@ -151,7 +153,7 @@
// used for benchmarking
int32 fBench1;
int32 fBench2;
-
+
ClientWindow *pClientWin (void) const;
entry_ref AppRef(void) const;
@@ -160,7 +162,7 @@
void InitSettings (void);
int32 ThreadStates (void);
bool CheckStartupNetworks (void);
-
+
volatile bool fShuttingDown;
AboutWindow *fAboutWin;
@@ -169,9 +171,9 @@
PrefsWindow *fPrefsWin;
NetworkWindow *fNetWin;
DCCFileWindow *fDccFileWin;
-
+
SettingsFile *fVisionSettings;
-
+
rgb_color fColors[MAX_COLORS];
BFont *fClientFont[MAX_FONTS];
BString fCommands[MAX_COMMANDS];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|