My favorites | Sign in
Project Home Downloads Issues
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php

/*
* Author:
* Abhinav Singh
*
* Contact:
* mailsforabhinav@gmail.com
* admin@abhinavsingh.com
*
* Site:
* http://abhinavsingh.com
* http://abhinavsingh.com/blog
*
* Source:
* http://code.google.com/p/jaxl
*
* About:
* JAXL stands for "Just Another XMPP Library"
* For geeks, JAXL stands for "Jabber XMPP Library"
*
* I wrote this library while developing Gtalkbots (http://gtalkbots.com)
* I have highly customized it to work with Gtalk Servers and inspite of
* production level usage at Gtalkbots, I recommend still not to use this
* for any live project.
*
* Feel free to add me in Gtalk and drop an IM.
*
*/

/*
* ==================================== IMPORTANT =========================================
* This is a sample application code showing the power of JAXL. How without knowing the
* inner tit-bits of XMPP protocols you can develop cool applications.
*
* To run this sample application you need:
* 1. JAXL Library version 1.0.4 or higher (http://code.google.com/p/jaxl)
* 2. PHP Mailer Class (http://phpmailer.codeworxtech.com/)
* ==================================== IMPORTANT =========================================
*/

/* Include PHP Mailer Class */
include_once("class.phpmailer.php");

/* Include XMPP Class */
include_once("xmpp.class.php");

class JAXL extends XMPP {

/* Define custom mail groups */
var $family = array("mom@gmail.com","dad@gmail.com");
var $colleague = array("boss@company.com","manager@company.com");

/* Define custom mail subject and message */
var $familySubject = "Hi, Will get back to you";
var $familyMessage = "Hey, I am currently out on vacation at my grannies house in Delhi. I will return back home by next monday.<br/>Reach out to me at +91-987654321.<br/><br/>With Love,<br/>Abhinav Singh";

/* Define custom mail subject and message */
var $colleagueSubject = "[Auto-Reply] Out of Office";
var $colleagueMessage = "Hi, I am on vacation in my village with very limited access to internet and phone. I will return back home by next monday.<br/><br/>Regards,<br/>Abhinav Singh";

function eventMessage($fromJid, $content, $offline = FALSE) {
// Not used here. See jaxl.class.php for it's use case
}

function eventPresence($fromJid, $status, $photo) {
// Not used here. See jaxl.class.php for it's use case
}

function eventNewEMail($total,$thread,$url,$participation,$messages,$date,$senders,$labels,$subject,$snippet) {
// We only want to send auto-reply message to latest sender
$sender = $senders[0];

// Check if the user lie in any category, and send appropriate mail
if(in_array($sender["address"],$this->family)) {
$mail = new PHPMailer();
$mail->From = "youremailid@gmail.com";
$mail->FromName = "Your Name";
$mail->Subject = $this->familySubject;
$mail->MsgHTML($this->familyMessage."<br/><br/>Powered by Jaxl http://code.google.com/p/jaxl");
$mail->IsHTML(true);
$mail->AddAddress($sender["address"],$sender["name"]);

if(!$mail->Send()) $this->logger->logger("Error occured while sending mail to ".$sender["address"]);
else $this->logger->logger("Mail sent successfully to ".$sender["address"]);
}
else if(in_array($sender["address"],$this->colleague)) {
$mail = new PHPMailer();
$mail->From = "youremailid@gmail.com";
$mail->FromName = "Your Name";
$mail->Subject = $this->colleagueSubject;
$mail->MsgHTML($this->colleagueMessage."<br/><br/>Powered by Jaxl http://code.google.com/p/jaxl");
$mail->IsHTML(true);
$mail->AddAddress($sender["address"],$sender["name"]);

if(!$mail->Send()) $this->logger->logger("Error occured while sending mail to ".$sender["address"]);
else $this->logger->logger("Mail sent successfully to ".$sender["address"]);
}
else {
// Do nothing, will handle later on
$this->logger->logger("No handler for this email id...");
}
}

function setStatus() {
print "Setting Status...\n";
$this->sendStatus("Available");

print "Requesting new mails...\n";
$this->getNewEMail();

print "Done\n";
}

}

?>

Change log

r40 by mailsforabhinav on May 20, 2009   Diff
Checking in with updates comments and
introducing jaxl4broadcast.class.php for
broadcasting IM across your buddy list
Go to: 
Project members, sign in to write a code review

Older revisions

r38 by mailsforabhinav on Feb 6, 2009   Diff
Version 1.0.4
-------------
Implementation of Google's Gmail
Extension http://code.google.com/apis/
talk/jep_extensions/gmail.html
...
All revisions of this file

File info

Size: 4579 bytes, 117 lines
Powered by Google Project Hosting