piviul

내 정보

개발자 정보
이름 piviul
가입한 날짜 2월 12, 2010
개발한 부가 기능 수 부가 기능 0개
이 개발자의 부가 기능의 평균 별점 아직 별점 없음

내 검토

Message Archive Options

5점중 5점 받음

Hi, the last 15th february I've send the patched overlay.js to eviljeff hoping in a fast update of the add-on. Because there are other interested in the patch I write the new overlay.js here:
--- begin overlay.js

var messagearchiveoptions = {

preferenceService: Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.messagearchiveoptions@eviljeff.com."),



get monthValue() {return this.preferenceService.getComplexValue("monthstring",Components.interfaces.nsISupportsString).toString();},

get yearValue() {return this.preferenceService.getComplexValue("yearstring", Components.interfaces.nsISupportsString).toString();},

get keyModifiers() {

var modifiers=new Array();

if (this.preferenceService.getBoolPref("key.shift")) modifiers.push("shift");

if (this.preferenceService.getBoolPref("key.alt")) modifiers.push("alt");

if (this.preferenceService.getBoolPref("key.control")) modifiers.push("accel");

return modifiers;

},

onLoad: function() {

BatchMessageMover.prototype.archiveSelectedMessages = function() {

gFolderDisplay.hintMassMoveStarting();

var selectedMessages = gFolderDisplay.selectedMessages;

if (!selectedMessages.length) {

return;

}

var messages = Components.classes['@mozilla.org/array;1'].createInstance(Components.interfaces.nsIMutableArray);

for (let i = 0; i < selectedMessages.length; ++i) {

let msgHdr = selectedMessages[i];

let server = msgHdr.folder.server;

let rootFolder = server.rootFolder;

let msgDate = new Date(msgHdr.date / 1000);

let fullPath = String(msgHdr.folder.URI).replace(server.serverURI, "").substring(1);

let rootPath = fullPath.substring(0, fullPath.indexOf('/', 1));

if (rootPath.length == 0) rootPath=fullPath;

let yearValue = messagearchiveoptions.yearValue.replace('%F', fullPath);

yearValue = yearValue.replace('%f', rootPath);

let msgYear = msgDate.toLocaleFormat(yearValue);

let monthValue = messagearchiveoptions.monthValue.replace('%F', fullPath);

monthValue = monthValue.replace('%f', rootPath);

let monthFolderName = msgDate.toLocaleFormat(monthValue);

let archiveFolderUri;

if (server.type == "rss") {

archiveFolderUri = server.serverURI + "/Archives";

} else {

let identity = getIdentityForServer(server);

if (!identity) {

identity = getIdentityForHeader(msgHdr);

}

archiveFolderUri = identity.archiveFolder;

}

let archiveFolder = GetMsgFolderFromUri(archiveFolderUri, false);

let granularity = archiveFolder.server.archiveGranularity;

let copyBatchKey = msgHdr.folder.URI + "\0";

if (granularity >= Components.interfaces.nsIMsgIncomingServer.perYearArchiveFolders) {

copyBatchKey += msgYear;

}

if (granularity >= Components.interfaces.nsIMsgIncomingServer.perMonthArchiveFolders) {

copyBatchKey += monthFolderName;

}

if (!(copyBatchKey in this._batches)) {

this._batches[copyBatchKey] = [msgHdr.folder, archiveFolderUri, granularity, msgYear, monthFolderName];

}

this._batches[copyBatchKey].push(msgHdr);

}

this.processNextBatch();

}

document.getElementById("key_archive").setAttribute("modifiers",this.keyModifiers.join(", "));

},

observe:function(subject ,topic , data) {

if (topic!="nsPref:changed") return;

document.getElementById("key_archive").setAttribute("modifiers",this.keyModifiers.join(", "));

}

};



window.addEventListener("load", function(e) { messagearchiveoptions.onLoad(e); }, false);

messagearchiveoptions.preferenceService.QueryInterface(Components.interfaces.nsIPrefBranch2).addObserver("key", messagearchiveoptions, false);

--- end
I've removed the license block so please don't delete it from the original overlay.js!

Have a grat day

Piviul

이 검토는 현재 부가 기능의 이전 (0.3.1) 버전에 대한 것입니다. 

Message Archive Options

5점중 4점 받음

We have done some little changes to overlay.js to have folder structure (root only or full structure) support permitting new %f (root structure) or %F (full structure) in the year and month options as asked from andras.tim, BlackForst and Illtud Daniel. This is de diff:
38,48c38,48
< preferenceService: Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.messagearchiveoptions@eviljeff.com."),
<
< get monthValue() {return this.preferenceService.getComplexValue("monthstring",Components.interfaces.nsISupportsString).toString();},
< get yearValue() {return this.preferenceService.getComplexValue("yearstring", Components.interfaces.nsISupportsString).toString();},
< get keyModifiers() {
< var modifiers=new Array();
< if (this.preferenceService.getBoolPref("key.shift")) modifiers.push("shift");
< if (this.preferenceService.getBoolPref("key.alt")) modifiers.push("alt");
< if (this.preferenceService.getBoolPref("key.control")) modifiers.push("accel");
< return modifiers;
< },
---
> preferenceService: Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.messagearchiveoptions@eviljeff.com."),
>
> get monthValue() {return this.preferenceService.getComplexValue("monthstring",Components.interfaces.nsISupportsString).toString();},
> get yearValue() {return this.preferenceService.getComplexValue("yearstring", Components.interfaces.nsISupportsString).toString();},
> get keyModifiers() {
> var modifiers=new Array();
> if (this.preferenceService.getBoolPref("key.shift")) modifiers.push("shift");
> if (this.preferenceService.getBoolPref("key.alt")) modifiers.push("alt");
> if (this.preferenceService.getBoolPref("key.control")) modifiers.push("accel");
> return modifiers;
> },
50,55c50,98
< var origfunc=BatchMessageMover.prototype.archiveSelectedMessages.toSource();
< origfunc=origfunc.replace('msgDate.toLocaleFormat("%Y-%m")','msgDate.toLocaleFormat(messagearchiveoptions.monthValue)');
< origfunc=origfunc.replace('msgDate.getFullYear().toString()','msgDate.toLocaleFormat(messagearchiveoptions.yearValue)');
< eval("BatchMessageMover.prototype.archiveSelectedMessages = "+origfunc);
< //BatchMessageMover.prototype.archiveSelectedMessages = this.archiveSelectedMessages;
<
---
> BatchMessageMover.prototype.archiveSelectedMessages = function() {
> gFolderDisplay.hintMassMoveStarting();
> var selectedMessages = gFolderDisplay.selectedMessages;
> if (!selectedMessages.length) {
> return;
> }
> var messages = Components.classes['@mozilla.org/array;1'].createInstance(Components.interfaces.nsIMutableArray);
> for (let i = 0; i < selectedMessages.length; ++i) {
> let msgHdr = selectedMessages[i];
> let server = msgHdr.folder.server;
> let rootFolder = server.rootFolder;
> let msgDate = new Date(msgHdr.date / 1000);
> //let msgYear = msgDate.toLocaleFormat(messagearchiveoptions.yearValue);
> //let monthFolderName = msgDate.toLocaleFormat(messagearchiveoptions.monthValue);
> let fullPath = String(msgHdr.folder.URI).replace(server.serverURI, "").substring(1);
> let rootPath = fullPath.substring(0, fullPath.indexOf('/', 1));
> if (rootPath.length == 0) rootPath=fullPath;
> let yearValue = messagearchiveoptions.yearValue.replace('%F', fullPath);
> yearValue = yearValue.replace('%f', rootPath);
> let msgYear = msgDate.toLocaleFormat(yearValue);
> let monthValue = messagearchiveoptions.monthValue.replace('%F', fullPath);
> monthValue = monthValue.replace('%f', rootPath);
> let monthFolderName = msgDate.toLocaleFormat(monthValue);
> let archiveFolderUri;
> if (server.type == "rss") {
> archiveFolderUri = server.serverURI + "/Archives";
> } else {
> let identity = getIdentityForServer(server);
> if (!identity) {
> identity = getIdentityForHeader(msgHdr);
> }
> archiveFolderUri = identity.archiveFolder;
> }
> let archiveFolder = GetMsgFolderFromUri(archiveFolderUri, false);
> let granularity = archiveFolder.server.archiveGranularity;
> let copyBatchKey = msgHdr.folder.URI + "\0";
> if (granularity >= Components.interfaces.nsIMsgIncomingServer.perYearArchiveFolders) {
> copyBatchKey += msgYear;
> }
> if (granularity >= Components.interfaces.nsIMsgIncomingServer.perMonthArchiveFolders) {
> copyBatchKey += monthFolderName;
> }
> if (!(copyBatchKey in this._batches)) {
> this._batches[copyBatchKey] = [msgHdr.folder, archiveFolderUri, granularity, msgYear, monthFolderName];
> }
> this._batches[copyBatchKey].push(msgHdr);
> }
> this.processNextBatch();
> }

Piviul

이 검토는 현재 부가 기능의 이전 (0.3.1) 버전에 대한 것입니다.