adding dialog notifications and partial vibration support
diff --git a/Res/index.html b/Res/index.html
index dfe0461..012bf7a 100755
--- a/Res/index.html
+++ b/Res/index.html
@@ -69,5 +69,13 @@
         <input onclick="findContact()" type="submit" value="Contact.find">

         <input onclick="removeContacts()" type="submit" value="Contact.remove">

      </div>

+     <!-- Notification -->

+     <h3>Contact</h3>

+     <div>

+        <input onclick="notificationAlert()" type="submit" value="Notification.alert">

+        <input onclick="notificationConfirm()" type="submit" value="Notification.confirm">

+        <input onclick="notificationVibrate()" type="submit" value="Notification.vibrate">

+        <input onclick="notificationBeep()" type="submit" value="Notification.beep">

+     </div>

 	</body>

 </html>

diff --git a/Res/main.js b/Res/main.js
index 0439bdb..a48f74d 100755
--- a/Res/main.js
+++ b/Res/main.js
@@ -311,3 +311,34 @@
 		alert(e.message);

 	}

 }

+

+// Notification

+

+function notificationAlert() {

+  var complete = function(button) {

+    debugPrint("Alert button clicked: "+button);

+  }

+  try {

+    navigator.notification.alert("This is an alert Dialog",complete, "Alert Title", "OK");

+  } catch(e) {

+    debugPrint(e.message);

+  }

+}

+

+function notificationConfirm() {

+  var complete = function(button) {

+    debugPrint("Alert button clicked: "+button);

+  }

+  try {

+    navigator.notification.confirm("This is an alert Dialog",complete, "Alert Title", "OK,Cancel");

+  } catch(e) {

+    debugPrint(e.message);

+  }

+}

+

+function notifictionVibrate() {

+

+}

+function notificationBeep() {

+

+}

diff --git a/Res/phonegap/notification.js b/Res/phonegap/notification.js
index 9c8f158..0e39a73 100644
--- a/Res/phonegap/notification.js
+++ b/Res/phonegap/notification.js
@@ -7,10 +7,54 @@
  * Copyright (c) 2010, IBM Corporation
  */
 
+MessageBox.MSGBOX_STYLE_NONE = 0;
+MessageBox.MSGBOX_STYLE_OK = 1;
+MessageBox.MSGBOX_STYLE_CANCEL = 2;
+MessageBox.MSGBOX_STYLE_OKCANCEL = 3;
+MessageBox.MSGBOX_STYLE_YESNO = 4;
+MessageBox.MSGBOX_STYLE_YESNOCANCEL = 5;
+MessageBox.MSGBOX_STYLE_ABORTRETRYIGNORE = 6;
+MessageBox.MSGBOX_STYLE_CANCELTRYCONTINUE = 7;
+MessageBox.MSGBOX_STYLE_RETRYCANCEL = 8;
+
 /**
  * This class provides access to notifications on the device.
  */
 function Notification() {
+  this.messageBox = new MessageBox("Test Alert", "This is an alert", "OK");
+}
+
+/*
+ * MessageBox: used by Bada to retrieve Dialog Information
+ */
+
+function MessageBox(title, message, messageBoxStyle) {
+  this.title = title;
+  this.message = message;
+  this.messageBoxStyle = messageBoxStyle;
+}
+
+labelsToBoxStyle = function(buttonLabels) {
+  if(!buttonLabels)
+    return MessageBox.MSGBOX_STYLE_NONE;
+  if(buttonLabels == "OK")
+    return MessageBox.MSGBOX_STYLE_OK;
+  if(buttonLabels == "Cancel")
+    return MessageBox.MSGBOX_STYLE_CANCEL;
+  if(buttonLabels == "OK,Cancel")
+    return MessageBox.MSGBOX_STYLE_OKCANCEL;
+  if(buttonLabels == "Yes,No")
+    return MessageBox.MSGBOX_STYLE_YESNO;
+  if(buttonLabels == "Yes,No,Cancel")
+    return MessageBox.MSGBOX_STYLE_YESNOCANCEL;
+  if(buttonLabels == "Abort,Retry,Ignore")
+    return MessageBox.MSGBOX_STYLE_ABORTRETRYIGNORE;
+  if(buttonLabels == "Cancel,Try,Continue")
+    return MessageBox.MSGBOX_STYLE_CANCELTRYCONTINUE;
+  if(buttonLabels == "Retry,Cancel")
+    return MessageBox.MSGBOX_STYLE_RETRYCANCEL;
+
+  return MessageBox.MSGBOX_STYLE_NONE;
 }
 
 /**
@@ -22,8 +66,8 @@
  */
 Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
     var _title = (title || "Alert");
-    var _buttonLabel = (buttonLabel || "OK");
-    PhoneGap.exec(completeCallback, null, 'Notification', 'alert', [message, _title, _buttonLabel]);
+    this.messageBox = new MessageBox(_title, message, labelsToBoxStyle(buttonLabel));
+    PhoneGap.exec(completeCallback, null, 'com.phonegap.Notification', 'alert', []);
 };
 
 /**
@@ -36,7 +80,8 @@
 Notification.prototype.confirm = function(message, resultCallback, title, buttonLabels) {
     var _title = (title || "Confirm");
     var _buttonLabels = (buttonLabels || "OK,Cancel");
-    return PhoneGap.exec(resultCallback, null, 'Notification', 'confirm', [message, _title, _buttonLabels]);
+    this.messageBox = new MessageBox(_title, message, labelsToBoxStyle(buttonLabels));
+    return PhoneGap.exec(resultCallback, null, 'com.phonegap.Notification', 'confirm', []);
 };
 
 /**
@@ -44,7 +89,7 @@
  * @param {Integer} mills The number of milliseconds to vibrate for.
  */
 Notification.prototype.vibrate = function(mills) {
-    PhoneGap.exec(null, null, 'Notification', 'vibrate', [mills]);
+    PhoneGap.exec(null, null, 'com.phonegap.Notification', 'vibrate', [mills]);
 };
 
 /**
@@ -52,7 +97,7 @@
  * @param {Integer} count The number of beeps.
  */
 Notification.prototype.beep = function(count) {
-    PhoneGap.exec(null, null, 'Notification', 'beep', [count]);
+    PhoneGap.exec(null, null, 'com.phonegap.Notification', 'beep', [count]);
 };
 
 PhoneGap.addConstructor(function() {
diff --git a/Res/phonegap/phonegap.bat b/Res/phonegap/phonegap.bat
index 348234c..2a6952a 100755
--- a/Res/phonegap/phonegap.bat
+++ b/Res/phonegap/phonegap.bat
@@ -1 +1 @@
-copy /B phonegap.base.js+geolocation.js+position.js+accelerometer.js+network.js+debugconsole.js+contact.js+device.js+compass.js phonegap.js
+copy /B phonegap.base.js+geolocation.js+position.js+accelerometer.js+network.js+debugconsole.js+contact.js+device.js+compass.js+notification.js phonegap.js
diff --git a/inc/Notification.h b/inc/Notification.h
new file mode 100755
index 0000000..6e48a96
--- /dev/null
+++ b/inc/Notification.h
@@ -0,0 +1,31 @@
+/*

+ * Notification.h

+ *

+ *  Created on: Apr 5, 2011

+ *      Author: Anis Kadri

+ */

+

+#ifndef NOTIFICATION_H_

+#define NOTIFICATION_H_

+

+#include <FUi.h>

+#include <FSystem.h>

+#include "PhoneGapCommand.h"

+using namespace Osp::System;

+using namespace Osp::Ui;

+using namespace Osp::Ui::Controls;

+

+class Notification: public PhoneGapCommand {

+public:

+	Notification(Web* pWeb);

+	virtual ~Notification();

+public:

+	String callbackId;

+public:

+	void Run(const String& command);

+	void Dialog();

+	void Vibrate();

+	void Beep();

+};

+

+#endif /* NOTIFICATION_H_ */

diff --git a/inc/WebForm.h b/inc/WebForm.h
index 02e216c..2cdad26 100755
--- a/inc/WebForm.h
+++ b/inc/WebForm.h
@@ -14,6 +14,7 @@
 #include "DebugConsole.h"

 #include "Compass.h"

 #include "Contacts.h"

+#include "Notification.h"

 

 using namespace Osp::Base;

 using namespace Osp::Base::Collection;

@@ -48,6 +49,7 @@
 	DebugConsole*				console;

 	Compass*					compass;

 	Contacts*					contacts;

+	Notification*				notification;

 	String*						__phonegapCommand;

 

 public:

diff --git a/src/Notification.cpp b/src/Notification.cpp
new file mode 100755
index 0000000..c44509b
--- /dev/null
+++ b/src/Notification.cpp
@@ -0,0 +1,122 @@
+/*

+ * Notification.cpp

+ *

+ *  Created on: Apr 5, 2011

+ *      Author: Anis Kadri

+ */

+

+#include "../inc/Notification.h"

+

+Notification::Notification(Web* pWeb) : PhoneGapCommand(pWeb) {

+}

+

+Notification::~Notification() {

+}

+

+void

+Notification::Run(const String& command) {

+	if(!command.IsEmpty()) {

+		Uri commandUri;

+		commandUri.SetUri(command);

+		String method = commandUri.GetHost();

+		StringTokenizer strTok(commandUri.GetPath(), L"/");

+		if(strTok.GetTokenCount() < 1) {

+			AppLogException("Not enough params");

+			return;

+		}

+		strTok.GetNextToken(callbackId);

+		AppLogDebug("%S %S", method.GetPointer(), callbackId.GetPointer());

+		if((method == L"com.phonegap.Notification.alert" || method == L"com.phonegap.Notification.confirm") && !callbackId.IsEmpty()) {

+			Dialog();

+		} else if(method == L"com.phonegap.Notification.vibrate" && !callbackId.IsEmpty()) {

+			//Vibrate();

+		} else if(method == L"com.phonegap.Notification.beep" && !callbackId.IsEmpty()) {

+			//Beep();

+		}

+	}

+}

+

+void

+Notification::Dialog() {

+	MessageBox messageBox;

+	String* title;

+	String* message;

+	String* styleStr;

+	String eval;

+

+	title = pWeb->EvaluateJavascriptN(L"navigator.notification.messageBox.title");

+	message = pWeb->EvaluateJavascriptN(L"navigator.notification.messageBox.message");

+	styleStr = pWeb->EvaluateJavascriptN(L"navigator.notification.messageBox.messageBoxStyle");

+

+	AppLogDebug("title %S message %S styleStr %S", title->GetPointer(), message->GetPointer(), styleStr->GetPointer());

+	if(!title->IsEmpty() && !message->IsEmpty() && !styleStr->IsEmpty()) {

+		int style;

+		int modalResult = 0;

+		if(Integer::Parse(*styleStr, style) != E_SUCCESS) {

+			AppLogException("Could not get dialog style");

+			return;

+		}

+		messageBox.Construct(*title, *message, (MessageBoxStyle)style, 0);

+		messageBox.ShowAndWait(modalResult);

+		switch(modalResult) {

+		case MSGBOX_RESULT_CLOSE:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('Close')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_OK:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('OK')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_CANCEL:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('Cancel')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_YES:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('Yes')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_NO:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('No')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_ABORT:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('Abort')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_TRY:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('Try')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_RETRY:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('Retry')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_IGNORE:

+			eval.Format(128, L"PhoneGap.callbacks['%S'].success('Ignore')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		case MSGBOX_RESULT_CONTINUE:

+			eval.Format(64, L"PhoneGap.callbacks['%S'].success('Continue')", callbackId.GetPointer());

+			pWeb->EvaluateJavascriptN(eval);

+			break;

+		}

+

+	} else {

+		AppLogException("Could not construct MessageBox");

+	}

+	delete title;

+	delete message;

+	delete styleStr;

+}

+void Notification::Vibrate() {

+	Vibrator vibrator;

+	vibrator.Construct();

+	vibrator.Start(3000,   // on period

+		           1000,  // off period

+		           2,   // repeat count

+		           60);   // vibration strength

+}

+

+void Notification::Beep() {

+

+}

diff --git a/src/WebForm.cpp b/src/WebForm.cpp
index 3c2e935..7ee542b 100755
--- a/src/WebForm.cpp
+++ b/src/WebForm.cpp
@@ -12,13 +12,7 @@
 	contacts = null;

 }

 

-WebForm::~WebForm(void)

-{

-//	delete __phonegapCommand;

-//	delete location;

-//	delete device;

-//	delete accel;

-//	delete network;

+WebForm::~WebForm(void) {

 }

 

 bool

@@ -54,8 +48,15 @@
 {

 	result r = E_SUCCESS;

 

-	// TODO: Add your termination code here

-

+//	delete __phonegapCommand;

+//	delete geolocation;

+//	delete device;

+//	delete accel;

+//	delete network;

+//	delete console;

+//	delete compass;

+//	delete contacts;

+//	delete notification;

 	return r;

 }

 

@@ -149,6 +150,9 @@
 		else if(__phonegapCommand->StartsWith(L"gap://com.phonegap.Contacts", 0)) {

 			contacts->Run(*__phonegapCommand);

 		}

+		else if(__phonegapCommand->StartsWith(L"gap://com.phonegap.Notification", 0)) {

+			notification->Run(*__phonegapCommand);

+		}

 		// Tell the JS code that we got this command, and we're ready for another

 		__pWeb->EvaluateJavascriptN(L"PhoneGap.queue.ready = true;");

 		delete __phonegapCommand;

@@ -193,6 +197,7 @@
 		console = new DebugConsole(__pWeb);

 		compass = new Compass(__pWeb);

 		contacts = new Contacts(__pWeb);

+		notification = new Notification(__pWeb);

 	}

 	return r;