Renamed more-icons-per-row-5x4-flare576
[webos-internals:adamrmcd-modifications.git] / email / readalldelall.patch
1 Adds delete all and read buttons to email folders
2 Index: /usr/palm/applications/com.palm.app.email/app/controllers/list-assistant.js
3 ===================================================================
4 --- .orig/usr/palm/applications/com.palm.app.email/app/controllers/list-assistant.js
5 +++ /usr/palm/applications/com.palm.app.email/app/controllers/list-assistant.js
6 @@ -33,6 +33,8 @@ var ListAssistant = Class.create(App.Sce
7                         visible:true,
8                         items: [
9                                 {label:$L('Compose'), icon:'compose', command:'compose'},
10 +                               {label:$L('Delete All'), icon:'delete', command:'deleteall'},
11 +                               {label:$L('All Read'), icon:'priority', command:'readall'},
12                                 {},
13                                 {label:$L('Update'), icon:'sync', command:'sync'}
14                         ]};
15 @@ -166,6 +168,14 @@ var ListAssistant = Class.create(App.Sce
16                         case 'sync':
17                                 this.handleSyncFolder();
18                                 break;
19 +                               
20 +                       case 'deleteall':
21 +                               this.handleDeleteAll();
22 +                               break;
23 +
24 +                       case 'readall':
25 +                               this.handleReadAll();
26 +                               break;
27  
28                         case Mojo.Menu.prefsCmd:
29                                 MenuController.showPrefs(this.controller.stageController);
30 @@ -182,6 +192,109 @@ var ListAssistant = Class.create(App.Sce
31                 event.stopPropagation();
32         }
33    },
34 +  
35 +  handleDeleteAllResponse: function (event) {
36 +        this.deleteAll();
37 +  },
38 +
39 +  deleteAll: function(){
40 +       var count = this.emailListElement.mojo.getLength();
41 +       var id;
42 +       if(count > 0) 
43 +       {       
44 +               var item = this.emailListElement.mojo.getNodeByIndex(0);        
45 +               if(item !== undefined)
46 +               {
47 +                  id = item.id;
48 +                  if(id)
49 +                  {
50 +                       this.controller.serviceRequest(Email.identifier, {
51 +                                       method: 'setDeleted',
52 +                                       parameters: {'message':id, 'value': true },
53 +                                       onSuccess: this.handleDeleteAllResponse.bind(this),
54 +                                       onFailure: this.handleDeleteAllResponse.bind(this)
55 +                                       });
56 +                  }
57 +               }
58 +               else
59 +               {
60 +                       this.deleteAll();                       
61 +               }
62 +       }
63 +  },
64 +
65 +  handleDeleteAll: function (event) {
66 +       var totalCount = 0;
67 +       totalCount = this.emailListElement.mojo.getLength();
68 +       if (totalCount > 0) {
69 +                                       this.controller.showAlertDialog({
70 +                             onChoose: function(value) {
71 +                                               if(value == 'yes') {
72 +                                                       this.deleteAll();
73 +                                                       }
74 +                                               },
75 +                                               title: '<b>' + $L('Delete All') + '</b>',
76 +                                               message: $L('Are you sure you want to delte all ') + "<b>" + totalCount + "</b>" + $L(' items in this folder?'),
77 +                                                       choices: [
78 +                                                               {label:$L('Yes'), value:'yes', type:'affirmative'},
79 +                                                       {label:$L('No'), value:'no', type:'alert'}
80 +                                                       ]
81 +                                       });
82 +                       }
83 +  },
84 +
85 +  handleReadAllResponse: function (event) {
86 +  },
87 +
88 +  readAll: function(tleft){
89 +       var count = this.emailListElement.mojo.getLength();
90 +       var id;
91 +       while(tleft > 0) 
92 +       {       
93 +               var item = this.emailListElement.mojo.getNodeByIndex((tleft - 1));      
94 +               if(item !== undefined)
95 +               {
96 +                  id = item.id;
97 +                  if(id)
98 +                  {
99 +                       this.controller.serviceRequest(Email.identifier, {
100 +                                       method: 'setRead',
101 +                                       parameters: {'message':id, 'value': true },
102 +                                       onSuccess: this.handleReadAllResponse.bind(this),
103 +                                       onFailure: this.handleReadAllResponse.bind(this)
104 +                                       });
105 +               }
106 +               tleft = tleft - 1;
107 +               }
108 +               else
109 +               {
110 +                       tleft = tleft - 1;
111 +               }
112 +       }       
113 +  },
114 +  
115 +
116 +  handleReadAll: function (event) {
117 +               var totalCount = 0;
118 +               totalCount = this.emailListElement.mojo.getLength();
119 +               if (totalCount > 0) {
120 +                       this.controller.showAlertDialog({
121 +                   onChoose: function(value) {
122 +                               if(value == 'yes') {
123 +                                               var tleft = totalCount;
124 +                                                       this.readAll(tleft);
125 +                       }
126 +                               },
127 +                       title: '<b>' + $L('All Read') + '</b>',
128 +                       message: $L('Are you sure you want to mark ') + "<b>" + totalCount + "</b>" + $L(' items in this folder read?'),
129 +                    choices: [
130 +                       {label:$L('Yes'), value:'yes', type:'affirmative'},
131 +                        {label:$L('No'), value:'no', type:'alert'}
132 +                    ]
133 +                       });
134 +               }
135 +  },
136 +
137         
138    handleSend: function() {
139         MenuController.showComposeView(null, this.folderObj.login);