Difference between revisions of "Patch Contacts Send All via Email"

From WebOS Internals
Jump to navigation Jump to search
m
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
  
 
This patch allows you to create a vCard file containing all your contacts, and then attach that file to an e-mail. WebOS does not offer a built-in way to export your contacts, so this seems to be the next best thing.
 
This patch allows you to create a vCard file containing all your contacts, and then attach that file to an e-mail. WebOS does not offer a built-in way to export your contacts, so this seems to be the next best thing.
 +
 +
If you only get one contact when you import the vCard file, you can either import it to Google or Hotmail and then export your contacts from there, or you can use a vCard splitter such as vCardOrganizer which will let you split the big vCard file into individual files for each contact.
  
 
===Patch Source (emailall.patch)===
 
===Patch Source (emailall.patch)===
  
 
<source lang="diff">
 
<source lang="diff">
--- /usr/palm/applications/com.palm.app.contacts/app/controllers/list-assistant.js.orig 2009-08-19 19:19:40.000000000 -0400
+
--- /usr/palm/applications/com.palm.app.contacts/app/controllers/list-assistant.js.orig
+++ /usr/palm/applications/com.palm.app.contacts/app/controllers/list-assistant.js 2010-01-08 01:11:12.380734400 -0500
+
+++ /usr/palm/applications/com.palm.app.contacts/app/controllers/list-assistant.js
@@ -284,6 +284,9 @@
+
@@ -290,6 +290,9 @@
  items: [Mojo.Menu.editItem,{
+
  }, {
 
  label:$L("Send All to Car Kit"),
 
  label:$L("Send All to Car Kit"),
 
  command:"sendcontacts"
 
  command:"sendcontacts"
 
+ }, {
 
+ }, {
+ label:$L("Save All via Email"),
+
+ label:$L("Send All via Email"),
 
+ command:"emailcontacts"
 
+ command:"emailcontacts"
 
  }, prefsItem, {
 
  }, prefsItem, {
 
  label: $LL('Help'),
 
  label: $LL('Help'),
 
  command: Mojo.Menu.helpCmd
 
  command: Mojo.Menu.helpCmd
@@ -463,12 +466,31 @@
+
@@ -476,6 +479,8 @@
 
  this.controller.stageController.pushScene('prefs');
 
  this.controller.stageController.pushScene('prefs');
 
  }else if (event.type == Mojo.Event.command && event.command == "sendcontacts") {
 
  }else if (event.type == Mojo.Event.command && event.command == "sendcontacts") {
Line 30: Line 32:
 
  if (event.type == Mojo.Event.commandEnable && event.command == Mojo.Menu.prefsCmd) {
 
  if (event.type == Mojo.Event.commandEnable && event.command == Mojo.Menu.prefsCmd) {
 
  // funkay!  this is apparently how you declare you want to activate the prefs menu item
 
  // funkay!  this is apparently how you declare you want to activate the prefs menu item
event.stopPropagation();
+
@@ -483,6 +488,23 @@
 
  }
 
  }
 
  },
 
  },
+   
+
+   emailContacts:function(){
+
+ emailContacts:function(){
+       this.vcardRequest = AppAssistant.contactsService.makeVCardList(this.controller, {
+
+ this.vcardRequest = AppAssistant.contactsService.makeVCardList(this.controller, {
+               stripPhoneNumbers:false
+
+ stripPhoneNumbers:false
+           }, this.gotVCard.bind(this, "email"));
+
+ }, this.gotVCard.bind(this, "email"));
+       var cancelFn = function(){
+
+ var cancelFn = function(){
+           this.vcardRequest.cancel();
+
+ this.vcardRequest.cancel();
+           this.vcardRequest = null;
+
+ this.vcardRequest = null;
+       }.bind(this)
+
+ }.bind(this)
+       console.log("Setting up a dialog");
+
+ console.log("Setting up a dialog");
+       this.sendContactsPopupAssistant = new SendContactsPopupAssistant(this.controller, cancelFn);
+
+ this.sendContactsPopupAssistant = new SendContactsPopupAssistant(this.controller, cancelFn);
+       this.controller.showDialog({
+
+ this.controller.showDialog({
+           template: 'list/send-contact-popup',
+
+ template: 'list/send-contact-popup',
+           assistant: this.sendContactsPopupAssistant,
+
+ assistant: this.sendContactsPopupAssistant,
+           preventCancel:true
+
+ preventCancel:true
+       });
+
+ });
 
+ },
 
+ },
+
+
 
  sendContacts:function(){
 
  sendContacts:function(){
 
 
 
 
@@ -479,7 +501,7 @@
+
var params = {"type":"bluetooth", "onSuccess":this.bluetoothResponse.bind(this)};
 +
@@ -492,7 +514,7 @@
 
 
 
 
 
  bluetoothResponse:function(response){
 
  bluetoothResponse:function(response){
Line 62: Line 65:
 
  this.vcardRequest.cancel();
 
  this.vcardRequest.cancel();
 
  this.vcardRequest = null;
 
  this.vcardRequest = null;
@@ -494,18 +516,39 @@
+
@@ -507,18 +529,39 @@
 
  }
 
  }
 
  },
 
  },
Line 70: Line 73:
 
- appId:"com.palm.app.bluetooth",
 
- appId:"com.palm.app.bluetooth",
 
- name:"btopp"
 
- name:"btopp"
- }
+
+ gotVCard:function(type, resp){
 +
+ if (type == "bluetooth") {
 +
+ var appArgs = {
 +
+ appId:"com.palm.app.bluetooth",
 +
+ name:"btopp"
 +
+ }
 +
+ var sceneArgs = {
 +
+ file:resp.file
 +
+ }
 +
+
 +
+ this.sendContactsPopupAssistant.widget.mojo.close();
 +
+
 +
+ this.controller.stageController.pushScene(appArgs, sceneArgs)
 +
}
 
- var sceneArgs = {
 
- var sceneArgs = {
 
- file:resp.file
 
- file:resp.file
- }
+
+ else if (type == "email") {
 +
+ var vcfPath = resp.file;
 +
+
 +
+ this.sendContactsPopupAssistant.widget.mojo.close();
 +
+
 +
+ this.controller.serviceRequest('palm://com.palm.applicationManager', {
 +
+ method: 'open',
 +
+ parameters: {
 +
+ id: 'com.palm.app.email',
 +
+ params: {
 +
+ summary: 'Palm Contacts',
 +
+ attachments: [{
 +
+ fullPath:vcfPath,
 +
+ mimeType:'text/x-vcard'
 +
+ }]
 +
+ }
 +
+ }
 +
+ });
 +
}
 
-
 
-
 
- this.sendContactsPopupAssistant.widget.mojo.close();
 
- this.sendContactsPopupAssistant.widget.mojo.close();
 
-
 
-
 
- this.controller.stageController.pushScene(appArgs, sceneArgs)
 
- this.controller.stageController.pushScene(appArgs, sceneArgs)
+ gotVCard:function(type, resp){
 
+        if (type == "bluetooth") {
 
+            var appArgs = {
 
+                appId:"com.palm.app.bluetooth",
 
+                name:"btopp"
 
+            }
 
+            var sceneArgs = {
 
+                file:resp.file
 
+            }
 
+           
 
+            this.sendContactsPopupAssistant.widget.mojo.close();
 
+           
 
+            this.controller.stageController.pushScene(appArgs, sceneArgs)
 
+        }
 
+        else if (type == "email") {
 
+            var vcfPath = resp.file;
 
+           
 
+            this.sendContactsPopupAssistant.widget.mojo.close();
 
+           
 
+            this.controller.serviceRequest('palm://com.palm.applicationManager', {
 
+     method: 'open',
 
+     parameters: {
 
+         id: 'com.palm.app.email',
 
+         params: {
 
+             summary: 'Palm Contacts',
 
+             attachments: [{
 
+                 fullPath:vcfPath,
 
+                 mimeType:'text/x-vcard'
 
+             }]
 
+         }
 
+     }
 
+ });
 
+        }
 
 
  },
 
  },
 
 
 
 
 
  handleListTap: function(event){
 
  handleListTap: function(event){
 
  
 
</source>
 
</source>

Latest revision as of 16:19, 9 July 2010


Send all via email.png

Introduction

This patch allows you to create a vCard file containing all your contacts, and then attach that file to an e-mail. WebOS does not offer a built-in way to export your contacts, so this seems to be the next best thing.

If you only get one contact when you import the vCard file, you can either import it to Google or Hotmail and then export your contacts from there, or you can use a vCard splitter such as vCardOrganizer which will let you split the big vCard file into individual files for each contact.

Patch Source (emailall.patch)

<source lang="diff"> --- /usr/palm/applications/com.palm.app.contacts/app/controllers/list-assistant.js.orig +++ /usr/palm/applications/com.palm.app.contacts/app/controllers/list-assistant.js @@ -290,6 +290,9 @@

				}, {
					label:$L("Send All to Car Kit"),
					command:"sendcontacts"

+ }, { + label:$L("Send All via Email"), + command:"emailcontacts"

				}, prefsItem, {
					label: $LL('Help'),
					command: Mojo.Menu.helpCmd

@@ -476,6 +479,8 @@

			this.controller.stageController.pushScene('prefs');
		}else if (event.type == Mojo.Event.command && event.command == "sendcontacts") {
			this.sendContacts();

+ }else if (event.type == Mojo.Event.command && event.command == "emailcontacts") { + this.emailContacts();

		}
		if (event.type == Mojo.Event.commandEnable && event.command == Mojo.Menu.prefsCmd) {
			// funkay!  this is apparently how you declare you want to activate the prefs menu item

@@ -483,6 +488,23 @@

		}
	},
	

+ emailContacts:function(){ + this.vcardRequest = AppAssistant.contactsService.makeVCardList(this.controller, { + stripPhoneNumbers:false + }, this.gotVCard.bind(this, "email")); + var cancelFn = function(){ + this.vcardRequest.cancel(); + this.vcardRequest = null; + }.bind(this) + console.log("Setting up a dialog"); + this.sendContactsPopupAssistant = new SendContactsPopupAssistant(this.controller, cancelFn); + this.controller.showDialog({ + template: 'list/send-contact-popup', + assistant: this.sendContactsPopupAssistant, + preventCancel:true + }); + }, +

	sendContacts:function(){
		
		var params = {"type":"bluetooth", "onSuccess":this.bluetoothResponse.bind(this)}; 

@@ -492,7 +514,7 @@

	bluetoothResponse:function(response){
		if (response == "BT-On" || response == "BT-StartingUp") {

- this.vcardRequest = AppAssistant.contactsService.makeVCardList(this.controller, {stripPhoneNumbers:true}, this.gotVCard.bind(this)); + this.vcardRequest = AppAssistant.contactsService.makeVCardList(this.controller, {stripPhoneNumbers:true}, this.gotVCard.bind(this, "bluetooth"));

			var cancelFn = function(){
				this.vcardRequest.cancel();
				this.vcardRequest = null;

@@ -507,18 +529,39 @@

		}
	},
	

- gotVCard:function(resp){ - var appArgs = { - appId:"com.palm.app.bluetooth", - name:"btopp" + gotVCard:function(type, resp){ + if (type == "bluetooth") { + var appArgs = { + appId:"com.palm.app.bluetooth", + name:"btopp" + } + var sceneArgs = { + file:resp.file + } + + this.sendContactsPopupAssistant.widget.mojo.close(); + + this.controller.stageController.pushScene(appArgs, sceneArgs)

		}

- var sceneArgs = { - file:resp.file + else if (type == "email") { + var vcfPath = resp.file; + + this.sendContactsPopupAssistant.widget.mojo.close(); + + this.controller.serviceRequest('palm://com.palm.applicationManager', { + method: 'open', + parameters: { + id: 'com.palm.app.email', + params: { + summary: 'Palm Contacts', + attachments: [{ + fullPath:vcfPath, + mimeType:'text/x-vcard' + }] + } + } + });

		}

- - this.sendContactsPopupAssistant.widget.mojo.close(); - - this.controller.stageController.pushScene(appArgs, sceneArgs)

	},
	
	handleListTap: function(event){

</source>