Results 1 to 8 of 8
  1.    #1  
    I'm fairly new to linux and ever since I rooted my Pre ive been able to apply patches with no issues until I tried the Email Delete All patch found here Patch Email DeleteAll - WebOS Internals after saving and rebooting I am able to open the email app but am not able to open email folders. not sure what I did wrong. How do most people apply the patches? I attempted copy and paste but it pasted the code all messed up so I basically went line by line. It all looks correct, not sure where my error was. I'm gonna look at a buddies code to revert back if I can't figure it out.
    Vis
  2. #2  
    Quote Originally Posted by Visualfx View Post
    I'm fairly new to linux and ever since I rooted my Pre ive been able to apply patches with no issues until I tried the Email Delete All patch found here Patch Email DeleteAll - WebOS Internals after saving and rebooting I am able to open the email app but am not able to open email folders. not sure what I did wrong. How do most people apply the patches? I attempted copy and paste but it pasted the code all messed up so I basically went line by line. It all looks correct, not sure where my error was. I'm gonna look at a buddies code to revert back if I can't figure it out.

    Applying Patches - WebOS Internals
  3.    #3  
    Ive read through all of that material but most seems like a foreign language to me. I have been just attempting to add patches via root using VI and for the most part It's been working out until now.
    Vis
  4. #4  
    Most likely you have missed a ";" or something somewhere.

    I have also had an issue with copy past using Putty and vi. If anyone knows how to fix this please post instructions.

    You could try using nano instead of vi, but i have not tried that myself yet.

    Or you could copy the file to your desktop/laptop edit using your favorite editor and then copy the file back to your Pre.
  5. #5  
    I use putty, however I never attempted this patch.
  6.    #6  
    These are the changes I've made can anyone see what i did wrong???

    this.cmdMenuModel = {
    visible:true,
    items: [
    {label:$L('Compose'), icon:'compose', command:'c
    {label:$L('Delete All'), icon:'delete', command:
    {label:$L('Update'), icon:'sync', command:'sync'
    ]};




    /**
    * handle a menu command.
    */
    handleCommand: function(event) {
    if (event.type == Mojo.Event.command) {
    switch (event.command) {
    case 'compose':
    this.handleSend();
    break;

    case 'sync':
    this.handleSyncFolder();
    break;

    case Mojo.Menu.prefsCmd:
    MenuController.showPrefs(this.controller.stageCo
    break;

    case Mojo.Menu.helpCmd:
    MenuController.showHelp();
    break;
    case 'deleteall':
    this.handleDeleteAll();
    break;
    }
    }

    handleDeleteAllResponse: function (event) {
    //check to see if there are more items to delete.
    this.deleteAll();
    },

    deleteAll: function(){

    var count = this.emailListElement.mojo.getLength();

    var id;

    if(count > 0)
    {
    var item = this.emailListElement.mojo.getNodeByIndex(0);

    if(item !== undefined)
    {
    id = item.id;

    if(id)
    {
    this.controller.serviceRequest(Email.identifier, {
    method: 'setDeleted',
    parameters: {'message':id, 'value': true
    onSuccess: this.handleDeleteAllResponse.
    onFailure: this.handleDeleteAllResponse.
    });
    }//if(id)
    }//if item !== undefined
    else
    {
    //item was undefined probably because it is currently ma
    this.deleteAll();
    }
    }//count > 0
    },

    handleDeleteAll: function (event) {

    var totalCount = 0;

    totalCount = this.emailListElement.mojo.getLength();

    this.controller.showAlertDialog({
    onChoose: function(value) {
    if(value == 'yes') {
    //Delete all items in thi
    this.deleteAll();
    }
    },
    title: '<b>' + $L('Delete All') +
    message: $L('Are you sure you want
    choices: [
    {label:$L('Yes'),
    {label:$L('No'), value:'no
    ]
    });
    },

    // Enable prefs & help menu items
    else if (event.type == Mojo.Event.commandEnable &&
    (event.command == Mojo.Menu.prefsCmd || event.command == Mojo.M





    any thoughts???
    Vis
  7. #7  
    It looks like you truncated some lines somehow. The cmdMenuModel should look like the following:

    Code:
    this.cmdMenuModel = {
                    visible:true,
                    items: [
                            {label:$L('Compose'), icon:'compose', command:'compose'},
                            {label:$L('Delete All'), icon:'delete', command:'deleteall'},
                            {label:$L('Update'), icon:'sync', command:'sync'}
                    ]};
  8. gerard187's Avatar
    Posts
    46 Posts
    Global Posts
    67 Global Posts
    #8  
    What am I doing wrong? I edited the file and I can't open my email folders.


    Code:
    /* Copyright 2009 Palm, Inc.  All rights reserved. */
    
    var ListAssistant = Class.create(App.Scene, {
     initialize : function($super, targetFolder, delaySetup) {
        $super(delaySetup);
      	this.folderObj = targetFolder;
    	this.folderSubscription = null;
    	this.folderErrorCount = 0;
    
    	// Runtime state:
    	this.numberOfDeletesSent = 0;
    
    	this.currentZoomItem = undefined;
    	this.currentZoomItemPreview = undefined;
    	this.currentZoomItemHeight = 0;
    	this.minListItemHeight = undefined;
    
        // Handlers:
        this.renderFolderDetailsHandler = this.renderFolderDetails.bind(this);
        this.folderErrorHandler = this.folderError.bind(this);
    	this.updateFolderStatusModelHandler = this.updateFolderStatusModel.bind(this)
    	this.deleteResponseHandler = this.handleDeleteResponse.bind(this);
    	this.gestureStartHandler = this.handleGestureStart.bind(this);
    	this.gestureHandler = this.handleGesture.bind(this);
     },
    
      setup: function() {	
    	this.notificationAssistant = Mojo.Controller.getAppController().assistant.notificationAssistant;
    	this.main = this.controller.get('main');
    	this.emptyMessage = this.controller.get('empty-list-message');
    
    	this.cmdMenuModel = {
    			visible:true,
    			items: [
    				{label:$L('Compose'), icon:'compose', command:'compose'},
    				{label:$L('Delete All'), icon:'delete', command:'deleteall'},
    				{label:$L('Update'), icon:'sync', command:'sync'}
    			]};
    	this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, this.cmdMenuModel);
            this.controller.window.PalmSystem.setWindowOrientation("free");
      },
    
      // NOTE: this is called by app_scene's _setup function
      setupDelayed: function() {
    	this.accDetailsReq = Folder.getFolderAccountDetail(this.folderObj.folderId, this.renderFolderHeader.bind(this));
    
        this.dataSource = new EmaillistDataSource(this.folderObj.folderId, 5, this.checkEmptyList.bind(this));
    
        // Set up the attributes & model for this widget:
    	var attributes = {
    					lookahead: 16,
    					renderLimit: 12,
    					fixedHeightItems:true,
    					itemTemplate: 'list/email_entry',
    					itemsCallback: this.dataSource.updateOffsetAndLimit.bind(this.dataSource),
    					swipeToDelete: true,
    					autoconfirmDelete: true,
    					uniquenessProperty: 'id',
    					dividerTemplate: 'list/date_separator',
    					dividerFunction: function(email) { return email.dateCategory; }
    		};
    	this.controller.setupWidget('email_list', attributes, {});
    	this.controller.instantiateChildWidgets(this.main);
    
    	this.emailListElement = this.controller.get('email_list');
    
        this.folderElement = this.controller.get('folder');
    	this.folderElement.observe(Mojo.Event.tap, this.headerTapped.bind(this));
    
    	// List observers
     	this.emailListElement.observe(Mojo.Event.listTap, this.handleClick.bindAsEventListener(this));
     	this.emailListElement.observe(Mojo.Event.listDelete, this.handleDelete.bindAsEventListener(this));
     	this.emailListElement.observe("gesturestart", this.gestureStartHandler, true);
     	this.emailListElement.observe("gesturechange", this.gestureHandler, true);
    
    	// Get the initial folder status in case no sync happens (since end of a sync is the
    	// other time folderStatus is requested)
    //	Folder.folderStatus(this.folderObj.folderId, this.updateFolderStatusModelHandler);
    
    	// Since the user is viewing this folder, request a sync right now.
    	Folder.syncFolder(this.folderObj.folderId, false);
    
    //	this.controller.getSceneScroller().mojo.updatePhysicsParameters({flickSpeed: 0.12, flickRatio: 0.25});
      },
    
      cleanup: function() {
      	if (this.emailListElement) {
    		this.emailListElement.stopObserving(Mojo.Event.listTap, this.handleClick);
    		this.emailListElement.stopObserving(Mojo.Event.listDelete, this.handleDelete);
    	}
    
    	this.dataSource.cleanup();
    	Folder.stopSyncFolder(this.folderObj.folderId);	
    	if (this.spinExecutor) {
    		this.spinExecutor.cancel(); //NOTE: this causes spinCleanup() to be executed
    	}
     },
    
      activate: function() {
      		// If the scene is invalid (usually because the underlying account was deleted), 
    		// just pop the scene and no more.
      		if (this.popOnActivate === true) {
    			this.controller.stageController.popScene();
    			return;
    		}
    
      		this.pauseSpinner = false;
    		// Tell the notification assistant that we're in a folder
    		// In the case of all inboxes, always ignore new email notifications  
    		if (this.setIgnoreNewEmails === true) {
    			this.notificationAssistant.setIgnoreNewEmails(true);
    			this.notificationAssistant.clear();
    		} else {
    			this.notificationAssistant.clear(this.folderObj.accountId, this.folderObj.folderId);
    		}
    		
    		// Delay the request for sync until late in the setup because it makes imap transport 
    		// do a lot of busy work that gets in the way of returning the list of existing emails. 
    		if (this.firstSync === undefined) {
    			this.firstSync = true;
    			// Since the user is viewing this folder, request a sync right now.
    			Folder.syncFolder(this.folderObj.folderId, false);
    		}
    
    		Mojo.Controller.getAppController().assistant.clearDebounce('f'+this.folderObj.folderId);		
      },
    
    	aboutToActivate: function(callback) {
    		// For now just delay 400 ms (aboutToActivate waits a max of 500ms anyway). 
    		// TODO there's several sources that need to fall into place for this scene to be ready for display:
    		//     1. on first activate, Header is ready
    		//     2. on first activate, List is ready
    		callback.delay(0.1);
    	},
    
    	deactivate: function() {
      		this.pauseSpinner = true;
    		this.notificationAssistant.setIgnoreNewEmails(false);
    	},
    
    	// This is called from accountpreference assistant when the user removes the account
    	accountDeletedNotification: function(accountId) {
    		if (accountId === this.folderObj.accountId) {
    			Mojo.Log.warn("ListAssistant is showing a deleted account, setting up for cleanup");
    			this.popOnActivate = true;
    		}
    	},
    
    	orientationChanged: function(orientation) {
    		if (orientation === "left" || orientation === "right") {
    			this.controller.sceneElement.addClassName('landscape');
    		} else {
    			this.controller.sceneElement.removeClassName('landscape');
    		}
    	},
    
      /**
       * handle a menu command.
       */
      handleCommand: function(event) {
    	if (event.type == Mojo.Event.command) {
    		switch (event.command) {
    			case 'compose':
    				this.handleSend();
    				break;
    
    			case 'sync':
    				this.handleSyncFolder();
    				break;
    
    			case Mojo.Menu.prefsCmd:
    				MenuController.showPrefs(this.controller.stageController);
    				break;
    
    			case Mojo.Menu.helpCmd:
    				MenuController.showHelp();
    				break;
    
    			case 'deleteall':
    				this.handleDeleteAll();
    				break;
    				
    		}
    	}
    	// Enable prefs & help menu items
    	else if (event.type == Mojo.Event.commandEnable && 
    	         (event.command == Mojo.Menu.prefsCmd || event.command == Mojo.Menu.helpCmd)) {
    		event.stopPropagation();
    	}
      },
    	
      handleSend: function() {
    	MenuController.showComposeView(null, this.folderObj.login);
      },
    	
      handleSyncFolder: function() {
    	Folder.syncFolder(this.folderObj.folderId, true);
    	// Fake a single cycle of sync animation to make the HI guys happy
    	this.simulateSyncAnimation();
      },
    
    	folderStatusModel: [{}],
    
    	handleGestureStart: function(e) {
    		var element = undefined;
    		Event.stop(e);
    		if (e.srcElement.id) {
    			element = e.srcElement;
    		} else {
    			element = e.srcElement.parentElement;
    			while (element.className.indexOf('email-entry') === -1) {
    				element = element.parentElement;
    			}
    		}
    
    		if (element === undefined || !element.id) {
    			this.currentZoomItem = undefined;
    		} else {
    			if (this.minListItemHeight === undefined) {
    				this.minListItemHeight = element.getHeight();
    			}
    
    			// keep zooming the current element, otherwise switch to a different element 
    			if (element === this.currentZoomItem) {
    				this.currentZoomItemHeight = element.getHeight();
    			} else {
    				this.currentZoomItem = element;
    				this.currentZoomItemPreview = element.down('.list-extended-preview');
    				this.currentZoomItemPreview.addClassName('zoomed');
    				this.currentZoomItemHeight = element.getHeight();
    
    				// Only request the message text for a list item once.
    				if (this.currentZoomItemPreview.innerHTML === "") {
    					this.controller.serviceRequest(Message.identifier, {
    							method: 'messageFileText',
    							parameters: { 'message':element.id },
    							onSuccess: function(resp) { element.down('.list-extended-preview').update(resp.text); },
    							onFailure: function() { Mojo.Log.error("messageFileText failed for id", element.id); }
    						});
    				}				
    			}
    		}
    	},
    
    	handleGesture: function(e) {
    		if (this.currentZoomItem !== undefined) {
    			var element;
    			Event.stop(e);
    			var newHeight = this.currentZoomItemHeight * e.scale;
    			if (newHeight < this.minListItemHeight) {
    				this.currentZoomItem.removeClassName('zoomed');
    			} else {
    				this.currentZoomItem.addClassName('zoomed');
    				this.currentZoomItem.setStyle({ height: newHeight + 'px' });
    				this.currentZoomItemPreview.setStyle({ height: (newHeight-54) + 'px' });
    			}
    		}
    	},
    
    	renderFolderHeader: function(folder) {
    		this.accDetailsReq = null;
    		this.folderType = folder.use;
    
    		// Make sure the folderObj includes these bits of info
    		this.folderObj.domain = folder.domain;
    		this.folderObj.login = folder.login;
    		this.folderObj.accountId = folder.accountId;
    
    		this.renderFolderDetails({record:folder});		
      	},
    
      renderFolderDetails: function(folder) {
      	// The subscription is successful so reset the error count.
      	this.folderErrorCount = 0;
    	
    	// Folder details have been updated so get folder sync status.
    	// Note, this may become unsafe if the transports start sending up
    	// folder details multiple times per second.
    	Folder.folderStatus(this.folderObj.folderId, this.updateFolderStatusModelHandler);
    	//console.log("*******Folder.folderStatus("+this.folderObj.folderId+")")  
    	
    	// The All Inboxes folder get a response with a list of folder details.
    	// Aggregate this into a single folder record.
    	if (folder.list) {
    		folder.record = {
    			unreadCount:0,
    			syncStatus:''
    		};
    		// If any of the accounts is in the process of syncing, then set the
    		// aggregate syncStatus so inboxes show the animation
    		folder.list.each(function(f) {
    			folder.record.unreadCount += f.unreadCount;
    			if (f.syncStatus && (f.syncStatus === "Syncing..." || f.syncStatus === "Receiving changes...")) {
    				folder.record.syncStatus = f.syncStatus;
    			}
    		});
    	}
    
      	folder.record.domain = FolderFlags.getFolderHeaderIcon(this.folderObj.domain);
    	if (folder.record.unreadCount > 0) {
    		folder.record.badgeDisplay = "block";
    	} else {
    		folder.record.badgeDisplay = "none";
    	}
    
    	var unreadDiv = undefined;
    	if (this.headerContent && this.unreadCountLength) {
    		unreadDiv = this.controller.get('folder-header-unread');
    		if (unreadDiv) {
    			unreadDiv.removeClassName(this.unreadCountLength);
    		}
    	}
    
    	var prevUnreadCountLength = this.unreadCountLength;
    	if (folder.record.unreadCount == 0) {
    		this.unreadCountLength = "count0";
    		this.lastFrameSync = 10;
    		this.lastFrameStop = 11;
    	} else if (folder.record.unreadCount < 10) {
    		this.unreadCountLength = "count1";
    		this.lastFrameSync = 10;
    		this.lastFrameStop = 18;
    	} else if (folder.record.unreadCount < 100) {
    		this.unreadCountLength = "count2";
    		this.lastFrameSync = 12;
    		this.lastFrameStop = 20;
    	} else if (folder.record.unreadCount < 1000) {
    		this.unreadCountLength = "count3";
    		this.lastFrameSync = 14;
    		this.lastFrameStop = 22;
    	} else {
    		this.unreadCountLength = "count4";
    		this.lastFrameSync = 16;
    		this.lastFrameStop = 24;
    	}
    	folder.record.unreadCountLength = this.unreadCountLength;	
    
    	if (unreadDiv) {
    		unreadDiv.addClassName(this.unreadCountLength);
    	}
    
    	// Only want to create this once, otherwise it will cause flickering in the sync animation
    	if (this.headerContent === undefined) {
    		if (folder.record.name) {
    			folder.record.name = $L(folder.record.name).escapeHTML();
    		}
    
    		// If the login is null then this is one of the synthetic folders (all inboxes or all unread)
    		if (folder.record.login === null) {
    			folder.record.domain = "synthetic-folder";
    		}
    
    	  	this.headerContent = Mojo.View.render({template: 'list/header_entry', object: folder.record});
    		this.folderElement.update(this.headerContent);
    		this.animationDiv = this.controller.get('sync-activity-animation');
    	} else {
    		unreadDiv.update(folder.record.unreadCount);
    		if (folder.record.unreadCount > 0) {
    			unreadDiv.show();
    			this.animationDiv.show();
    			if (prevUnreadCountLength) {
    				this.animationDiv.removeClassName(prevUnreadCountLength);
    			}
    			this.animationDiv.addClassName(this.unreadCountLength);
    		} else {
    			unreadDiv.hide();
    			// If the animation is currently going, don't hide it.
    			if (!this.spinExecutor) {
    				this.animationDiv.hide();
    			}
    		}
    	}
    
    	Mojo.Log.info("syncStatus="+folder.record.syncStatus);
    	if (folder.record.syncStatus &&
    		(folder.record.syncStatus === "Syncing..." || folder.record.syncStatus === "Receiving changes...")) {
    		this.startSyncAnimation();
    	} else {
    		//"Synced at "
    		//"Watching..." / "Waiting for new mail..."
    		//"Login failed..."
    		this.requestStopSyncAnimation();
    	}
      },
    
    	headerTapped: function (event) {
    		if (this.folderStatusModel.length > 1 || this.folderStatusModel[0].label !== undefined) {
    			var params = { 
    				placeNear:event.target, 
    				items:this.folderStatusModel, 
    				onChoose:this.handleStatusPopupSelect.bind(this)
    			};
    			this.controller.popupSubmenu(params);
    		}
    	},
    
      handleClick: function (event) {
    	var id = event.item.id;
    	if (id) {
    		var flags = event.item.flags;
    		if (this.folderType === "DRAFTS" 
    				|| (this.folderType === "OUTBOX" && ((flags & EmailFlags.errorBit) !== 0))) {
    			// draft emails and emails stuck in outbox that is marked as error
    			// will be able to be editable when it is clicked.
    			this.controller.serviceRequest('palm://com.palm.applicationManager', {
                        method: 'open',
                        parameters: {
    						id: 'com.palm.app.email',
    						params: { "draftId": id }
    					}
                    });
    		} else {
    			this.controller.stageController.pushScene('message', id, this.folderObj.folderId, undefined, event.item);
    		}
    	}
      },
    
      handleDelete: function (event) {
    	Mojo.Log.info("ListAssistant: setDeleted ", event.item.id);
    	this.controller.serviceRequest(Email.identifier, {
    			method: 'setDeleted',
    			parameters: {'message':event.item.id, 'value': true },
    			onSuccess: this.deleteResponseHandler,
    			onFailure: this.deleteResponseHandler
    		});
    	// Disable throttler requests while data is being deleted.  The data may be stale
    	// we know that the service has done executing the delete.
    	if (this.numberOfDeletesSent === 0) {
    		this.dataSource.throttler.disable();
    	}
    	this.numberOfDeletesSent++;
    	Mojo.Log.info("ListAssistant.handleDelete ref count=", this.numberOfDeletesSent);
      },
    
      handleDeleteResponse: function (event) {
    	this.numberOfDeletesSent--;
    	Mojo.Log.info("ListAssistant.handleDeleteResponse ref count=", this.numberOfDeletesSent);
    	if (this.numberOfDeletesSent <= 0) { // Defensive check.
    		// Time to re-enable the throttler now:
    		this.dataSource.throttler.enable(false);
    		this.numberOfDeletesSent = 0; // in case there we get repeated deleted messages.
    	}
      },
    
      updateFolderStatusModel: function(response) {
    	if (!response.folders) {
    		Mojo.Log.warn("updateFolderStatusModel got unexpected response ", Object.toJSON(response))
    		return;
    	}
    
    	// Don't show notifications for All Unread or any of the other synthetic folders.
    	if (response.folders.length > 1 && this.isActivated === true && this.isVisible === true && this.isMaximized === true) {
    		this.setIgnoreNewEmails = true;
    		if (this.notificationAssistant === undefined) {
    			this.notificationAssistant = Mojo.Controller.getAppController().assistant.notificationAssistant;
    		}
    		this.notificationAssistant.setIgnoreNewEmails(this.setIgnoreNewEmails);
    		this.notificationAssistant.clear();
    	}
    
    	this.folderStatusModel = [];
    	var isError = false;
    	var f = function(folder) {
    		if (this.processFolderStatus(folder) === true) {
    			isError = true;
    		}
    	}.bind(this);
    	response.folders.each(f);
    	// Set the error state if any of the accounts has an error.
    	this.showErrorState(isError);
    
    	//this.controller.modelChanged(this.folderStatusModel);
      },
    
    	processFolderStatus: function(folder) {
    		var formattedDate;
    		var isError = false;
    		var lastUpdatedStr = "";
    		var totalEmails = "";
    		var lastSyncTime = folder.lastSyncTime;
    		var popupItemCommand = 'noop';
    		if (Object.isString(lastSyncTime)) {
    			lastSyncTime = parseInt(lastSyncTime);
    		}
    		if (lastSyncTime > 0) {
    			formattedDate = ListAssistant.syncDate(lastSyncTime);
    			lastUpdatedStr = $L("Updated #{date}<br>").interpolate({date:formattedDate});
    		} else {
    			lastUpdatedStr = $L("Not yet updated") + "<br>";
    		}
    
    		if (folder.totalCount) {
    			totalEmails = $L("Total emails <b>#{totalCount}</b>").interpolate(folder);
    		}
    
    		var nextUpdateStr;
    		if (folder.syncType === undefined) {
    			// If no syncType, then this must be the just the total count
    			nextUpdateStr = "";
    			if (folder.totalCount) {
    				folder.domain = "generic";
    				lastUpdatedStr = "";
    			}
    		} else {
    			var syncType = (folder.syncType & 0xF); // Strip off unwanted status flags 
    			if (syncType == Folder.SYNC_SCHEDULED) {
    				if (folder.nextSyncTime === undefined) {
    					nextUpdateStr = "";
    					Mojo.Log.error("nextSyncTime missing ", $H(folder).inspect());
    				} else {
    					var minutes = Math.round(folder.nextSyncTime/60);
    					nextUpdateStr = $L("Next update in #{nextSync} minutes<br>").interpolate({nextSync:minutes});
    				}
    			} else if (syncType == Folder.SYNC_ONLINE || syncType == Folder.SYNC_NEW) {
    				if (lastSyncTime == 0) {
    					Mojo.Log.warn("WARNING: Folder has lastSyncTime == 0, using now")
    					var now = new Date();
    					formattedDate = ListAssistant.syncDate(now.getTime());
    					lastUpdatedStr = $L("Updated #{date}<br>").interpolate({date:formattedDate});
    				}
    				nextUpdateStr = "";
    			} else if (syncType == Folder.SYNC_OFFLINE) {
    				nextUpdateStr = $L("Press sync button to update") + "<br>";
    			} else {
    				nextUpdateStr = "";
    				totalEmails = "";
    				lastUpdatedStr = $L("No update information");
    			}
    		}
    
    		/*
    		 * First display any errors related to the folder
    		 */
    		var errorText;
    		switch (folder.syncStatus) {
    		case Folder.STATUS_LOGIN_FAILED:
    			isError = true;
    			errorText = $L("Login credentials rejected. Update your password");
    			var account = folder.account || this.folderObj.accountId;
    			popupItemCommand = "loginfailed-" + account;
    			break;
    
    		// This was added specifically for live.com which can lock out a user for 15 minutes,
    		// but could be used by other servers that have similar behavior
    		case Folder.STATUS_ACCOUNT_UNAVAILABLE:
    			isError = true;
    			errorText = $L("The account is temporarily unavailable. Please try again in a few minutes.");
    			break;
    
    		case Folder.STATUS_TRANSIENT_ERROR:
    			isError = true;
    			Mojo.Log.error("Got transient error from transport")
    			break;
    
    		default:
    			isError = false;
    		}
    
    		/*
    		 * Second display status text for the folder
    		 */
    		var renderParams = {
    			template: 'list/folder_details',
    			object: {
    				accountName: folder.accountName,
    				folderStatusText: lastUpdatedStr + nextUpdateStr + totalEmails,
    				errorText: errorText
    			}
    		};
    		var statusModelEntry = {
    			label: Mojo.View.render(renderParams),
     			command: popupItemCommand
    		};
    		if (folder.domain) {
    			statusModelEntry.secondaryIcon = "folder-status-icon "+folder.domain;
    		}
    	  	this.folderStatusModel.push(statusModelEntry);
    		
    		return isError;
    	},
    
    	showErrorState: function(isError) {
    		//var unreadElement = this.controller.get('sync-activity-animation');
    		var warningIcon = this.controller.get('header-warning-icon');
    		if (isError) {
    			this.isError = true;
    			//unreadElement.hide();
    			warningIcon.show();
    		} else {
    			this.isError = false;
    			//unreadElement.show();
    			warningIcon.hide();
    		}
    	},
    
    	folderError: function(err) {
    		// If there was a serious error that knocked the mailservice off dbus, stop
    		// the sync animation otherwise it may go on forever.
    		this.requestStopSyncAnimation();
    
    		// Try relaunching the mail service 3 times before giving up
    		this.folderErrorCount++;
    		if (this.folderErrorCount < 3) {
    			Mojo.Log.warn("list folderErrorCount=" + this.folderErrorCount + " detail=" + $H(err).inspect());
    			this.folderSubscription.cancel();
    		 	this.folderSubscription =
                    Folder.subscribeFolderDetail(this.folderObj.folderId,
                                                 this.renderFolderDetailsHandler,
                                                 this.folderErrorHandler);
    		} else {
    			Mojo.Log.error("This Is Bad: list cannot maintain folderList subscription " + $H(err).inspect());
    		}
    	},
    
    	handleStatusPopupSelect: function(value) {
    		if (value) {
    			var a = value.split("-");
    			if (a[0] === "loginfailed") {
    				var accountId = a[1];
    				this.controller.stageController.popScene('list');
    				this.controller.stageController.pushScene('create', { edit:true, id:accountId, type:"email" });
    			}
    		}
    	},
    
    	simulateSyncAnimation: function() {
    		if (this.spinExecutor) {
    			Mojo.Log.info("simulatedSyncAnimation: already spinning");
    		} else {
    			this.unreadElement = this.controller.get('folder-header-unread');
    			this.unreadElement.removeClassName("inside-pill");
    			this.currentFrame = 0;
    			var spinTimeout = 900; // 15 minutes is a long time for the spinner to go.
    			this.frameToDraw = Mojo.Animation.targetFPS/10;
    	        var options = {onComplete: this.spinCleanup.bind(this),
    						   from: 0,
    						   to: 128,
    						   duration: spinTimeout};
    			this.spinExecutor = Mojo.Animation.animateValue(Mojo.Animation.queueForElement(this.animationDiv),
    															'linear',
    															this.spinSyncAnimation.bind(this),
    															options);
    			this.animationDiv.show();
    		}
    	},
    
    	startSyncAnimation: function() {
    		if (this.spinExecutor) {
    			Mojo.Log.info("startSyncAnimation: already spinning");
    			this.continueAnimation = true;
    		} else {
    			Mojo.Log.info("startSyncAnimation: spinning up");
    
    			this.unreadElement = this.controller.get('folder-header-unread');
    			this.unreadElement.removeClassName("inside-pill");
    			this.currentFrame = 0;
    			this.continueAnimation = true;
    			var spinTimeout = 900; // 15 minutes is a long time for the spinner to go.
    			this.frameToDraw = Mojo.Animation.targetFPS/10;
    	        var options = {onComplete: this.spinCleanup.bind(this),
    						   from: 0,
    						   to: 128,
    						   duration: spinTimeout};
    			this.spinExecutor = Mojo.Animation.animateValue(Mojo.Animation.queueForElement(this.animationDiv),
    															'linear',
    															this.spinSyncAnimation.bind(this),
    															options);
    			this.animationDiv.show();
    		}
    	},
    
    	/*
    	 * The animation needs to complete its current cycle before stopping so
    	 * this only sets continueAnimation to false 
    	 */
    	requestStopSyncAnimation: function() {
    		Mojo.Log.info("requestStopSyncAnimation");
    		this.continueAnimation = false;
    	},
    
    	spinSyncAnimation: function(value) {
    		if (this.pauseSpinner) {
    			if (!this.continueAnimation) {
    				// Stop the spin animation
    				this.stopSyncAnimation();
    			}
    			return;
    		}
    
    		// Only want to udate the animation every 1/10 of a second
    		if (this.frameToDraw < Mojo.Animation.targetFPS/10) {
    			this.frameToDraw += 1;
    			return; // EXIT out because this is an intermediate call
    		} else {
    			this.frameToDraw = 0;
    		}
    
    		var prevFrame = this.currentFrame;
    		this.currentFrame += 1;
    
    		if (this.currentFrame > this.lastFrameSync) {
    			// At the end of the animation cycle. If the animation should not continue,
    			// stop the spinExecutor
    			if (this.continueAnimation) {
    				this.currentFrame = 1;
    			} else {
    				// When sync is done, there's a few frames of ending animation to display
    				if (this.currentFrame > this.lastFrameStop) {
    					// Stop the spin animation
    					this.stopSyncAnimation();
    				}
    			}
    		}
    
    		if (this.animationDiv && this.unreadElement) {
    			if (this.spinExecutor) {
    				this.animationDiv.addClassName("frame" + this.currentFrame);
    				this.unreadElement.addClassName("frame" + this.currentFrame);
    			}
    			this.animationDiv.removeClassName("frame" + prevFrame);
    			this.unreadElement.removeClassName("frame" + prevFrame);
    		}
    	},
    
    	stopSyncAnimation: function() {
    		Mojo.Log.info("stopSyncAnimation");
    		if (this.spinExecutor) {
    			this.spinExecutor.cancel(); //NOTE: this causes spinCleanup() to be executed
    			this.spinExecutor = null;
    		}
    	},
    
    	spinCleanup: function() {
            this.animationDiv.removeClassName("frame" + this.currentFrame);
    		this.unreadElement.removeClassName("frame" + this.currentFrame);
    		this.unreadElement.addClassName("inside-pill");
    		if (this.unreadCountLength == "count0") {
    			this.animationDiv.hide();
    		}
    
    		// Since a synchronization just finished, check whether the list is empty.
    		// The delay is necessary because the list data source also has a 1 second
    		// delay before it updates its count.
    		this.checkEmptyList.bind(this).delay(1);
    
    		Mojo.Log.info("stopSyncAnimation done!");
        },
    
        checkEmptyList: function() {
    		if (this.controller === undefined) {
    			return;
    		}
    
    		// Don't show the empty message if the transport is in the middle of syncing (continueAnimation is set).
    		// But immediately hide the empty message whenever the list has items in it irrespective of syncing state.
    		var listLength = this.dataSource.getListLength();
    		if (listLength === 0) {
    			if (this.continueAnimation === false) {
    				Mojo.Log.info("ListAssistant: No emails in this folder so showing the 'empty' message");
    				this.emptyMessage.show();
    			}
    		} else {
    			this.emptyMessage.hide();
    		}
    	},
    
        setupSubscriptions: function() {
            if (!this.folderSubscription) {
                this.folderSubscription =
                    Folder.subscribeFolderDetail(this.folderObj.folderId,
                                                 this.renderFolderDetailsHandler,
                                                 this.folderErrorHandler);
            }
        },
        cleanupSubscriptions: function() {
            if (this.folderSubscription) {
                this.folderSubscription.cancel();
                this.folderSubscription = null;
            }
        },
        enableSubscriptions: function() {
            this.setupSubscriptions();
            this.dataSource.enableSubscription();
        },
        disableSubscriptions: function() {
            this.dataSource.disableSubscription();
            this.cleanupSubscriptions();
        },
        maximizeSubscriptions: function() {
            // TODO: maximize this.folderSubscription.
            this.dataSource.maximizeSubscription();
        },
        minimizeSubscriptions: function() {
            this.dataSource.minimizeSubscription();
            // TODO: minimize this.folderSubscription.
        }
    });
    
    ListAssistant.syncDate = function(timestamp) {
          	var now = new Date();
    		var yesterday = new Date();
    		yesterday.setHours(0, 0, 0, 0);
    		var yesterdayTime = yesterday.getTime();
    		var d = new Date(timestamp);
     	  	if (timestamp > yesterdayTime) {
     	  		return "<b>"+ Mojo.Format.formatDate(d, {time:'short'}) +"</b>";
     	  	}
     	  	else {
     	  		return "<b>"+ Mojo.Format.formatDate(d, {date:'short'}) +"</b>";
     	  	}
    	};
    
     handleDeleteAllResponse: function (event) {
            //check to see if there are more items to delete.
            this.deleteAll();
      },
    
      deleteAll: function(){
      
      	var count = this.emailListElement.mojo.getLength();
    
    	var id;
    
    	if(count > 0) 
    	{	
    		var item = this.emailListElement.mojo.getNodeByIndex(0);	
    	
    		if(item !== undefined)
    		{
    		   id = item.id;
    		
    		   if(id)
    		   {
    			this.controller.serviceRequest(Email.identifier, {
    			        	method: 'setDeleted',
    			                parameters: {'message':id, 'value': true },
    			                onSuccess: this.handleDeleteAllResponse.bind(this),
    			                onFailure: this.handleDeleteAllResponse.bind(this)
    	             			});
    	     	   }//if(id)
    		}//if item !== undefined
    		else
    		{
    			//item was undefined probably because it is currently marked for delete
    			this.deleteAll();			
    		}
    	}//count > 0
      },
    
      handleDeleteAll: function (event) {
       	
    	var totalCount = 0;
    	
    	totalCount = this.emailListElement.mojo.getLength();
    	
    	this.controller.showAlertDialog({
                                 onChoose: function(value) {
      	                              		if(value == 'yes') {
    							//Delete all items in this folder
    							this.deleteAll();
    	                        	        	}
    						},
    	                                	title: '<b>' + $L('Delete All') + '</b>',
                          				message: $L('Are you sure you want to delte all ') + "<b>" + totalCount + "</b>" + $L(' items in this folder?'),
                           				choices: [
                                   				{label:$L('Yes'), value:'yes', type:'affirmative'},
                                        			{label:$L('No'), value:'no', type:'alert'}
                                                     	]
                    			});
      },

Posting Permissions