Bug 40974 - Save a list of away messages to the chatzilla profile using the new serializer.
ChatZilla only. r=samuel git-svn-id: svn://10.0.0.236/trunk@185654 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
124efa49cb
commit
cbb2d3166b
@ -13,6 +13,7 @@ chatzilla.jar:
|
||||
content/chatzilla/lib/js/irc-debug.js (js/lib/irc-debug.js)
|
||||
content/chatzilla/lib/js/file-utils.js (js/lib/file-utils.js)
|
||||
content/chatzilla/lib/js/dcc.js (js/lib/dcc.js)
|
||||
content/chatzilla/lib/js/text-serializer.js (js/lib/text-serializer.js)
|
||||
content/chatzilla/lib/xul/munger.js (xul/lib/munger.js)
|
||||
content/chatzilla/lib/xul/tree-utils.js (xul/lib/tree-utils.js)
|
||||
content/chatzilla/chatzilla.xul (xul/content/chatzilla.xul)
|
||||
|
||||
@ -2572,6 +2572,38 @@ function cmdAway(e)
|
||||
if (!e.reason)
|
||||
e.reason = MSG_AWAY_DEFAULT;
|
||||
|
||||
// Update away list (remove from current location).
|
||||
for (var i = 0; i < client.awayMsgs.length; i++)
|
||||
{
|
||||
if (client.awayMsgs[i].message == e.reason)
|
||||
{
|
||||
client.awayMsgs.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Always put new item at start.
|
||||
var newMsg = { message: e.reason };
|
||||
client.awayMsgs.unshift(newMsg);
|
||||
// Make sure we've not exceeded the limit set.
|
||||
if (client.awayMsgs.length > client.awayMsgCount)
|
||||
client.awayMsgs.splice(client.awayMsgCount);
|
||||
// And now, to save the list!
|
||||
try
|
||||
{
|
||||
var awayFile = new nsLocalFile(client.prefs["profilePath"]);
|
||||
awayFile.append("awayMsgs.txt");
|
||||
var awayLoader = new TextSerializer(awayFile);
|
||||
if (awayLoader.open(">"))
|
||||
{
|
||||
awayLoader.serialize(client.awayMsgs);
|
||||
awayLoader.close();
|
||||
}
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
display(getMsg(MSG_ERR_AWAY_SAVE, formatException(ex)), MT_ERROR);
|
||||
}
|
||||
|
||||
if (e.server)
|
||||
{
|
||||
if (e.network.state == NET_ONLINE)
|
||||
|
||||
@ -70,6 +70,7 @@
|
||||
<script src="chrome://chatzilla/content/lib/js/irc-debug.js"/>
|
||||
<script src="chrome://chatzilla/content/lib/js/file-utils.js"/>
|
||||
<script src="chrome://chatzilla/content/lib/js/dcc.js"/>
|
||||
<script src="chrome://chatzilla/content/lib/js/text-serializer.js"/>
|
||||
<script src="chrome://chatzilla/content/lib/xul/munger.js"/>
|
||||
|
||||
<script src="chrome://chatzilla/content/static.js"/>
|
||||
|
||||
@ -43,7 +43,7 @@ const __cz_version = "0.9.67+";
|
||||
const __cz_condition = "green";
|
||||
const __cz_suffix = "";
|
||||
const __cz_guid = "59c81df5-4b7a-477b-912d-4e0fdf64e5f2";
|
||||
const __cz_locale = "0.9.67.3";
|
||||
const __cz_locale = "0.9.67.4";
|
||||
|
||||
var warn;
|
||||
var ASSERT;
|
||||
@ -116,6 +116,8 @@ client.inputHistory = new Array();
|
||||
client.lastHistoryReferenced = -1;
|
||||
client.incompleteLine = "";
|
||||
client.lastTabUp = new Date();
|
||||
client.awayMsgs = new Array();
|
||||
client.awayMsgCount = 5;
|
||||
|
||||
CIRCNetwork.prototype.INITIAL_CHANNEL = "";
|
||||
CIRCNetwork.prototype.MAX_MESSAGES = 100;
|
||||
@ -343,6 +345,34 @@ function initStatic()
|
||||
setInterval("onNotifyTimeout()", client.NOTIFY_TIMEOUT);
|
||||
setInterval("onWhoTimeout()", client.AWAY_TIMEOUT);
|
||||
|
||||
client.awayMsgs = [{ message: MSG_AWAY_DEFAULT }];
|
||||
var awayFile = new nsLocalFile(client.prefs["profilePath"]);
|
||||
awayFile.append("awayMsgs.txt");
|
||||
if (awayFile.exists())
|
||||
{
|
||||
var awayLoader = new TextSerializer(awayFile);
|
||||
if (awayLoader.open("<"))
|
||||
{
|
||||
// Load the first item from the file.
|
||||
var item = awayLoader.deserialize();
|
||||
if (item instanceof Array)
|
||||
{
|
||||
// If the first item is an array, it is the entire thing.
|
||||
client.awayMsgs = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not an array, so we have the old format of a single object
|
||||
* per entry.
|
||||
*/
|
||||
client.awayMsgs = [item];
|
||||
while ((item = awayLoader.deserialize()))
|
||||
client.awayMsgs.push(item);
|
||||
}
|
||||
awayLoader.close();
|
||||
}
|
||||
}
|
||||
|
||||
client.defaultCompletion = client.COMMAND_CHAR + "help ";
|
||||
|
||||
client.deck = document.getElementById('output-deck');
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
#
|
||||
### End of notes ###
|
||||
|
||||
locale.version = 0.9.67.3
|
||||
locale.version = 0.9.67.4
|
||||
locale.error = You are using ChatZilla %1$S, which requires the locale version %2$S. The currently selected locale, %3$S, is version %4$S, and therefore there may be problems running ChatZilla.\n\nIt is strongly advised that you update or remove the ChatZilla locale in question.
|
||||
|
||||
# Misc
|
||||
@ -112,6 +112,7 @@ cmd.attach.params = <irc-url>
|
||||
cmd.attach.help = Attaches to the IRC URL specified by <irc-url>. If you are already attached, the view for <irc-url> is made current. If that view has been deleted, it is recreated. You may omit the irc:// portion of the <irc-url>. Examples are; /attach moznet, /attach moznet/chatzilla, and /attach irc.mozilla.org/mozbot,isnick.
|
||||
|
||||
cmd.away.label = Away (default)
|
||||
cmd.away.format = Away ($reason)
|
||||
cmd.away.params = [<reason>]
|
||||
cmd.away.help = If <reason> is specified, sets you away with that message. Used without <reason>, you are marked away with a default message.
|
||||
|
||||
@ -716,6 +717,7 @@ msg.err.unknown.host = The host application URL "%S" is not recognised. Please
|
||||
msg.err.unable.to.print = The current view does not support printing.
|
||||
msg.err.unsupported.command = The server does not support the ``%S'' command.
|
||||
msg.err.invalid.mode = The mode string you entered (``%S'') is invalid. A valid mode string consists of one or more sequences of a + or - followed by one or more alphabetical characters.
|
||||
msg.err.away.save = Saving the list of away messages failed (%S).
|
||||
|
||||
# Ask for oper pass if not explicitly given in the command:
|
||||
msg.need.oper.password = Please enter a password for obtaining IRC Operator privileges.
|
||||
@ -1123,7 +1125,7 @@ msg.someone.gone = "%S was booted from %S by %S (%S)
|
||||
|
||||
msg.mode.changed = Mode %S by %S"
|
||||
|
||||
msg.away.on = You are now marked as away (%S).
|
||||
msg.away.on = You are now marked as away (%S). Click the nickname button or use the |/back| command to return from being away.
|
||||
msg.away.off = You are no longer marked as away.
|
||||
msg.away.prompt = Enter an away message to use:
|
||||
msg.away.default = User is away.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user