summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--workspace/BlaMail/.classpath8
-rw-r--r--workspace/BlaMail/.project33
-rw-r--r--workspace/BlaMail/AndroidManifest.xml26
-rw-r--r--workspace/BlaMail/bin/BlaMail.apkbin0 -> 235057 bytes
-rw-r--r--workspace/BlaMail/bin/classes.dexbin0 -> 476252 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.classbin0 -> 1306 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.classbin0 -> 1348 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.classbin0 -> 1174 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/BlaMail.classbin0 -> 3849 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/R$attr.classbin0 -> 343 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/R$drawable.classbin0 -> 403 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/R$id.classbin0 -> 442 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/R$layout.classbin0 -> 397 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/R$string.classbin0 -> 430 bytes
-rw-r--r--workspace/BlaMail/bin/com/blatech/blamail/R.classbin0 -> 538 bytes
-rw-r--r--workspace/BlaMail/bin/resources.ap_bin0 -> 11064 bytes
-rw-r--r--workspace/BlaMail/default.properties11
-rw-r--r--workspace/BlaMail/gen/com/blatech/blamail/R.java28
-rw-r--r--workspace/BlaMail/lib/mail.jarbin0 -> 462098 bytes
-rw-r--r--workspace/BlaMail/res/drawable-hdpi/icon.pngbin0 -> 4147 bytes
-rw-r--r--workspace/BlaMail/res/drawable-ldpi/icon.pngbin0 -> 1723 bytes
-rw-r--r--workspace/BlaMail/res/drawable-mdpi/icon.pngbin0 -> 2574 bytes
-rw-r--r--workspace/BlaMail/res/layout/main.xml24
-rw-r--r--workspace/BlaMail/res/values/strings.xml5
-rw-r--r--workspace/BlaMail/src/com/blatech/blamail/BlaMail.java184
25 files changed, 319 insertions, 0 deletions
diff --git a/workspace/BlaMail/.classpath b/workspace/BlaMail/.classpath
new file mode 100644
index 0000000..75d908e
--- /dev/null
+++ b/workspace/BlaMail/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="lib" path="/home/Luke/workspace/BlaMail/lib/mail.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/workspace/BlaMail/.project b/workspace/BlaMail/.project
new file mode 100644
index 0000000..78a194b
--- /dev/null
+++ b/workspace/BlaMail/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>BlaMail</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/workspace/BlaMail/AndroidManifest.xml b/workspace/BlaMail/AndroidManifest.xml
new file mode 100644
index 0000000..cc5d549
--- /dev/null
+++ b/workspace/BlaMail/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.blatech.blamail"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
+ <activity android:name=".BlaMail"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+
+ <uses-permission android:name="com.android.email.permission.ACCESS_PROVIDER">
+ </uses-permission>
+
+ <uses-permission android:name="android.permission.INTERNET">
+ </uses-permission>
+
+ <uses-permission android:name="android.permission.SEND_SMS">
+ </uses-permission>
+
+</manifest> \ No newline at end of file
diff --git a/workspace/BlaMail/bin/BlaMail.apk b/workspace/BlaMail/bin/BlaMail.apk
new file mode 100644
index 0000000..59acad9
--- /dev/null
+++ b/workspace/BlaMail/bin/BlaMail.apk
Binary files differ
diff --git a/workspace/BlaMail/bin/classes.dex b/workspace/BlaMail/bin/classes.dex
new file mode 100644
index 0000000..b94b7e2
--- /dev/null
+++ b/workspace/BlaMail/bin/classes.dex
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class
new file mode 100644
index 0000000..310ff58
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$1.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class
new file mode 100644
index 0000000..55ab08d
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$2.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class
new file mode 100644
index 0000000..c341144
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail$3.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class
new file mode 100644
index 0000000..d94243d
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/BlaMail.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/R$attr.class b/workspace/BlaMail/bin/com/blatech/blamail/R$attr.class
new file mode 100644
index 0000000..ce6d52b
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/R$attr.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/R$drawable.class b/workspace/BlaMail/bin/com/blatech/blamail/R$drawable.class
new file mode 100644
index 0000000..ecd2ebf
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/R$drawable.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/R$id.class b/workspace/BlaMail/bin/com/blatech/blamail/R$id.class
new file mode 100644
index 0000000..6e920ae
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/R$id.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/R$layout.class b/workspace/BlaMail/bin/com/blatech/blamail/R$layout.class
new file mode 100644
index 0000000..fa8bc2f
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/R$layout.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/R$string.class b/workspace/BlaMail/bin/com/blatech/blamail/R$string.class
new file mode 100644
index 0000000..80f6101
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/R$string.class
Binary files differ
diff --git a/workspace/BlaMail/bin/com/blatech/blamail/R.class b/workspace/BlaMail/bin/com/blatech/blamail/R.class
new file mode 100644
index 0000000..363c764
--- /dev/null
+++ b/workspace/BlaMail/bin/com/blatech/blamail/R.class
Binary files differ
diff --git a/workspace/BlaMail/bin/resources.ap_ b/workspace/BlaMail/bin/resources.ap_
new file mode 100644
index 0000000..246f124
--- /dev/null
+++ b/workspace/BlaMail/bin/resources.ap_
Binary files differ
diff --git a/workspace/BlaMail/default.properties b/workspace/BlaMail/default.properties
new file mode 100644
index 0000000..0b9250e
--- /dev/null
+++ b/workspace/BlaMail/default.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/workspace/BlaMail/gen/com/blatech/blamail/R.java b/workspace/BlaMail/gen/com/blatech/blamail/R.java
new file mode 100644
index 0000000..5d804f0
--- /dev/null
+++ b/workspace/BlaMail/gen/com/blatech/blamail/R.java
@@ -0,0 +1,28 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.blatech.blamail;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int icon=0x7f020000;
+ }
+ public static final class id {
+ public static final int label=0x7f050000;
+ public static final int send=0x7f050002;
+ public static final int text=0x7f050001;
+ }
+ public static final class layout {
+ public static final int main=0x7f030000;
+ }
+ public static final class string {
+ public static final int app_name=0x7f040001;
+ public static final int hello=0x7f040000;
+ }
+}
diff --git a/workspace/BlaMail/lib/mail.jar b/workspace/BlaMail/lib/mail.jar
new file mode 100644
index 0000000..d1a4971
--- /dev/null
+++ b/workspace/BlaMail/lib/mail.jar
Binary files differ
diff --git a/workspace/BlaMail/res/drawable-hdpi/icon.png b/workspace/BlaMail/res/drawable-hdpi/icon.png
new file mode 100644
index 0000000..8074c4c
--- /dev/null
+++ b/workspace/BlaMail/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/workspace/BlaMail/res/drawable-ldpi/icon.png b/workspace/BlaMail/res/drawable-ldpi/icon.png
new file mode 100644
index 0000000..1095584
--- /dev/null
+++ b/workspace/BlaMail/res/drawable-ldpi/icon.png
Binary files differ
diff --git a/workspace/BlaMail/res/drawable-mdpi/icon.png b/workspace/BlaMail/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000..a07c69f
--- /dev/null
+++ b/workspace/BlaMail/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/workspace/BlaMail/res/layout/main.xml b/workspace/BlaMail/res/layout/main.xml
new file mode 100644
index 0000000..a770573
--- /dev/null
+++ b/workspace/BlaMail/res/layout/main.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <TextView
+ android:id="@+id/label"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="SMS Text:"/>
+ <EditText
+ android:id="@+id/text"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@android:drawable/editbox_background"
+ android:layout_below="@id/label"/>
+ <Button
+ android:id="@+id/send"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/text"
+ android:layout_alignParentRight="true"
+ android:layout_marginLeft="10dip"
+ android:text="Send" />
+</RelativeLayout>
diff --git a/workspace/BlaMail/res/values/strings.xml b/workspace/BlaMail/res/values/strings.xml
new file mode 100644
index 0000000..74490b2
--- /dev/null
+++ b/workspace/BlaMail/res/values/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, BlaMail!</string>
+ <string name="app_name">blamail</string>
+</resources>
diff --git a/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java
new file mode 100644
index 0000000..864afec
--- /dev/null
+++ b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java
@@ -0,0 +1,184 @@
+/* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.blatech.blamail;
+
+import java.util.Properties;
+
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Store;
+import javax.mail.event.MessageCountAdapter;
+import javax.mail.event.MessageCountEvent;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.telephony.SmsManager;
+import android.widget.Toast;
+
+import com.sun.mail.imap.IMAPFolder;
+
+public class BlaMail extends Activity {
+
+ String host = "imap.gmail.com";
+ String user = "blamailtest@gmail.com";
+ String pass = "thankssueaddo";
+ String mbox = "Inbox";
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ /** monitor e-mail */
+ try {
+ Properties props = new Properties();
+ //IMAPS protocol
+ props.setProperty("mail.store.protocol", "imaps");
+
+ //Set host address
+ props.setProperty("mail.imaps.host", "imaps.gmail.com");
+ //Set specified port
+ props.setProperty("mail.imaps.port", "993");
+ //Using SSL
+ props.setProperty("mail.imaps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
+ props.setProperty("mail.imaps.socketFactory.fallback", "false");
+ //Setting IMAP session
+ Session imapSession = Session.getInstance(props);
+
+ Store store = imapSession.getStore("imaps");
+
+ store.connect(host, user, pass);
+
+ //Get all mails in Inbox Forlder
+ Folder folder = store.getFolder(mbox);
+ if (folder == null || !folder.exists()) {
+ //System.out.println("Invalid folder");
+ Toast.makeText(getBaseContext(), "Invalid Folder",
+ Toast.LENGTH_SHORT).show();
+ System.exit(1);
+ }
+ folder.open(Folder.READ_ONLY);
+
+ // Add messageCountListener to listen for new messages
+ folder.addMessageCountListener(new MessageCountAdapter() {
+ public void messagesAdded(MessageCountEvent ev) {
+ Message[] msgs = ev.getMessages();
+ try {
+ sendSMS(msgs[0].getSubject().substring(0, 13), msgs[0].getSubject().substring(14));
+ } catch (MessagingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+
+ IMAPFolder f = (IMAPFolder)folder;
+ for(;;){
+ f.idle();
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ //---sends an SMS message to another device---
+ public void sendSMS(String phoneNumber, String message)
+ {
+ String SENT = "SMS_SENT";
+ String DELIVERED = "SMS_DELIVERED";
+
+ PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
+ new Intent(SENT), 0);
+
+ PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
+ new Intent(DELIVERED), 0);
+
+ //---when the SMS has been sent---
+ registerReceiver(new BroadcastReceiver(){
+ @Override
+ public void onReceive(Context arg0, Intent arg1) {
+ switch (getResultCode())
+ {
+ case Activity.RESULT_OK:
+ Toast.makeText(getBaseContext(), "SMS sent",
+ Toast.LENGTH_SHORT).show();
+ break;
+ case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
+ Toast.makeText(getBaseContext(), "Generic failure",
+ Toast.LENGTH_SHORT).show();
+ break;
+ case SmsManager.RESULT_ERROR_NO_SERVICE:
+ Toast.makeText(getBaseContext(), "No service",
+ Toast.LENGTH_SHORT).show();
+ break;
+ case SmsManager.RESULT_ERROR_NULL_PDU:
+ Toast.makeText(getBaseContext(), "Null PDU",
+ Toast.LENGTH_SHORT).show();
+ break;
+ case SmsManager.RESULT_ERROR_RADIO_OFF:
+ Toast.makeText(getBaseContext(), "Radio off",
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+ }, new IntentFilter(SENT));
+
+ //---when the SMS has been delivered---
+ registerReceiver(new BroadcastReceiver(){
+ @Override
+ public void onReceive(Context arg0, Intent arg1) {
+ switch (getResultCode())
+ {
+ case Activity.RESULT_OK:
+ Toast.makeText(getBaseContext(), "SMS delivered",
+ Toast.LENGTH_SHORT).show();
+ break;
+ case Activity.RESULT_CANCELED:
+ Toast.makeText(getBaseContext(), "SMS not delivered",
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+ }, new IntentFilter(DELIVERED));
+
+ SmsManager sms = SmsManager.getDefault();
+ sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
+
+}} \ No newline at end of file