Posts Tagged ‘AIR’
I updated Gravity Mail.
This version features is “Tag” based management messages.
I want to make e-mail client application like my blog site using e-mail for my private purposes.
This page is Gravity Mail information page in Japanese.
But some images help you to understand it. I hope….
I am making e-mail client application using Adobe AIR.
Please see the details.
But this application is in development.
I released airxmail version 0.7.
New feature
IMAP4
If you use draft implementation, please change this version.
I made a class for syslog output for Adobe AIR.
Because I want to see logs using linux “tail” & “grep” command.
Download:
coltware_airxlib_log_r3.swc on code.google.com
Class name: UDPSyslogTarget.as
How to use UDPSyslogTarget
import com.coltware.airxlib.log.UDPSyslogTarget;
var syslog:UDPSyslogTarget = new UDPSyslogTarget("192.168.1.5");
syslog.facility = UDPSyslogTarget.LOG_LOCAL1;
syslog.program = "AdobeAIR";
syslog.filters = ["com.coltware.*"];
syslog.level = LogEventLevel.DEBUG;
syslog.includeCategory = true;
Log.addTarget(syslog);
Line 3. Set hostname and port(default is 514)
Line 4. Set facility
Line 5. Set program name
Other properties are same as TraceTarget class.
If you don’t know how to use TraceTarget, please see HERE.
output sample
Feb 1 23:46:01 [info] AdobeAIR: com.coltware.airxlib.db.DBManager create if not exists table .... invoked Feb 1 23:46:02 [info] AdobeAIR: com.coltware.airxlib.db.DBManager TABLE CREATE OK Feb 1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [1/7] [SQL:] CREATE TABLE IF NOT EXISTS project( Feb 1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [2/7] sysid INTEGER PRIMARY KEY AUTOINCREMENT , Feb 1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [3/7] title TEXT NOT NULL , Feb 1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [4/7] createdAt DATE NOT NULL , Feb 1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [5/7] updatedAt DATE NOT NULL , Feb 1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [6/7] createdBy INTEGER , Feb 1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [7/7] updatedBy INTEGER );
rsyslog conf(sample)
$template air,"%timegenerated% [%syslogseverity-text%] %programname%: %msg%" local1.* /var/log/air.log;air
Can’t get email from POP3 or IMAP4 server with Airxmail.
Can’t send email to SMTP server with Airxmail.
But Why ?
But It is difficult to make the answer.
Because Airxmail is a library to communicate servers.
So you should know which is the problem, server or client ?
But How ??
Airxmail library support flex logging(mx.logging) functions.
So you can get debug logs using this functions.
The log text show you the communication between server and client.
1.Log sample ( IMAP and POP3 )
2.How to use flex logging functions.
2-1 ) Output using standard( trace() ) classes.
2-2 ) Output to file instead of trace()
Log sample
IMAP4
com.coltware.airxmail.imap.IMAP4Client set auth : xxxxxxxx@xxxxxx.com com.coltware.airxmail_internal.IMAP4 CMD[AX1000 CAPABILITY] com.coltware.airxmail_internal.IMAP4 CMD[AX1001 LOGIN username password] com.coltware.airxmail_internal.IMAP4 CMD[AX1002 NAMESPACE] com.coltware.airxmail_internal.IMAP4 CMD[AX1003 LSUB "" "*"] com.coltware.airxmail_internal.IMAP4 CMD[AX1004 SELECT "INBOX"] com.coltware.airxmail.imap.command.SelectCommand OK... com.coltware.airxmail_internal.IMAP4 CMD[AX1005 UID SEARCH SENTSINCE 1-Nov-2010] com.coltware.airxmail.imap.command.IMAP4Command line>* SEARCH 237 238 239 240 241 com.coltware.airxmail_internal.IMAP4 CMD[AX1006 UID FETCH 241 RFC822.HEADER] com.coltware.airxmail.MimeBodyPart create part object : [xxxx][object MimeMessage] com.coltware.airxmail_internal.IMAP4 CMD[AX1007 UID FETCH 240 RFC822.HEADER] com.coltware.airxmail.MimeBodyPart create part object : [xxxx][object MimeMessage] com.coltware.airxmail_internal.IMAP4 CMD[AX1008 UID FETCH 239 RFC822.HEADER] com.coltware.airxmail_internal.IMAP4 CMD[AX1051 SELECT "&TtVOiw-"] com.coltware.airxmail_internal.IMAP4 CMD[AX1052 SELECT "&ZcWITA-"] com.coltware.airxmail_internal.IMAP4 CMD[AX1053 LOGOUT]
“com.coltware.airxmail_internal.IMAP4 CMD[AXxxxx” is a request.
POP3
com.coltware.airxmail.pop3.POP3Client handleNotServiceReady : com.coltware.airxmail.pop3.POP3Client [NO] +OK mail.hosname.ne.jp POP Gateway starting. <7877.94.1295676023hostname.com> com.coltware.airxmail.pop3.POP3Client exec[USER username] com.coltware.airxmail.pop3.POP3Client USER>+OK Password required for usename@hostname.com. com.coltware.airxmail.pop3.POP3Client exec[PASS xxxxxxx] com.coltware.airxmail.pop3.POP3Client PASS>+OK username@hostname.com 8 message(s) (45468 octets). com.coltware.airxmail.pop3.POP3Client exec[UIDL] com.coltware.airxmail.pop3.POP3Client UIDL>+OK uidl command accepted. com.coltware.airxmail.pop3.POP3Client UIDL>1 798898888666525F84ZX55365F999671U com.coltware.airxmail.pop3.POP3Client UIDL>2 798898888278645F84ZX54365F99986YX com.coltware.airxmail.pop3.POP3Client UIDL>3 798898868173705F84ZX5Z365F99930YZ com.coltware.airxmail.pop3.POP3Client UIDL>4 798898858076435F84ZX52365F999679W com.coltware.airxmail.pop3.POP3Client UIDL>5 798898857787865F84ZX54365F99978Z4 com.coltware.airxmail.pop3.POP3Client UIDL>6 798898828171545F84ZX54365F9996X0Z com.coltware.airxmail.pop3.POP3Client UIDL>7 798898808643695F84ZX51365F9994ZUX com.coltware.airxmail.pop3.POP3Client UIDL>8 798898798097665F84ZX5V365F9998X3V com.coltware.airxmail.pop3.POP3Client UIDL>. com.coltware.airxmail.pop3.POP3Client exec[TOP 8 0] com.coltware.airxmail.pop3.POP3Client [RETR]+OK 3082 octets com.coltware.airxmail.pop3.POP3Client exec[QUIT]
2.How to use flex logging functions
Flex logging function is not depends output facility.
So you can decide the log output facility.
1st step: explain how to use flex logging using the class in FLEX SDK ( not depends on any library to output log )
2nd step: explain how to write log file using my classes
Because standard classes in FLEX SDK in only support standard output(?) ( trace() output ) as far as I know.
2-1 )
import mx.logging.Log;
import mx.logging.LogEventLevel;
import mx.logging.LogLogger;
import mx.logging.targets.TraceTarget;
private function init():void{
var logTarget:TraceTarget = new TraceTarget();
logTarget.filters = ["*"];
logTarget.includeCategory = true;
logTarget.level = LogEventLevel.DEBUG;
Log.addTarget(logTarget);
}
Please invoke init method in your initialize step.
In my usual case, I write these code.
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:local="*" creationComplete="init()">
That's all.
You don't need to write stace() function in your code.
You can see these code in airxmail library.
private static const log:ILogger = Log.getLogger("com.coltware.airxmail.imap.IMAP4Client");
private static const _log:ILogger = Log.getLogger("com.coltware.airxmail_internal.IMAP4");
:
_log.debug("CMD[" + cmd + "]");
Airxmail output a log automatically using flex logging functions.
You can see more detail at livedocs.adobe.com.
Flex logging function is many functions , like filter output and change output format etc ...
Current Airxmail subversion repository version has these 2 category.
"com.coltware.airxmail_internal.*" is low level log like protocol debug.
"com.coltware.airxmail.*" is more user level log.
But there was not clearly border, so please check the source code if you want to know more detail.
2-2 )
use FileTarget class in airxlib library.
FileTarget class support to write log file on your desktop pc.
import com.coltware.airxlib.log.FileTarget;
private function init():void{
var fileTarget:FileTarget = new FileTarget();
fileTarget.directory = File.desktopDirectory; // set directory path
fileTarget.filename = "airxmail.log"; // set filename
fileTarget.append = false;
fileTarget.filters = ["*"];
fileTarget.includeCategory = true;
fileTarget.level = LogEventLevel.DEBUG;
Log.addTarget(fileTarget);
}
I made air app that it convert o’reilly ebook app file to epub file.
STEP1 ) Buy o’reilly ebooks from Android market.


If ebook app support to export epub format, please use it. But some app doesn’t support ….
ex) Flex4 Cookbook, and etc ….
Then Go on the Next Step….
STEP2 ) copy to sdcard from apk file using appMonster or other app…..
STEP3 ) mount android to PC using USB cable.
STEP4 ) Install “export epub” app and execute it.
STEP5 ) Drag and drop to the following image. Then wait a minute.
Screen shows “DONE” label. Then you can find epub file in the same directory.
———————————————————————————-
Reference:
http://oreilly.com/ebooks/oreilly_iphone_tips.csp
I don’t know the app can extract epub file from iPhone app because I don’t have mac and iphone.
———————————————————————————–
This air application use airxzip library.
airxzip library is as3 zip library for Adobe AIR.
I made airxmail swc file on google codes.
The file is draft implemetation version for IMAP4.
So if you don’t want to use draft version, please wait…
It doen’t support IMAP4 all functions.
But it is available to get e-mail message from imap server, like gmail imap.
These code are sample to connect and get message from gmail account.
Create client instance
import com.coltware.airxmail.imap.IMAP4Client;
:
private var client:IMAP4Client;
public function init():void{
client = new IMAP4Client;
client.host = "imap.gmail.com";
client.port = 993;
client.socketObject = new SecureSocket();
}
mail flow to connect and get e-mail
// Set handler for Folder Result client.addEventListener(IMAP4Event.IMAP4_FOLDER_RESULT,folderListResult); // Set handler for UID list result ( uid is a key to get e-mail from server ) client.addEventListener(IMAP4ListEvent.IMAP4_RESULT_UID_LIST,uidList); // Set message handler client.addEventListener(IMAP4MessageEvent.IMAP4_MESSAGE,handleMessage); // Set username and password, and invoked connect method client.setAuth(username,password); client.connect(); client.login(); // get subscribed folder list client.lsubBlocking(); // logout client.logout();
Implemantation of folder result handler
private function folderListResult(event:IMAP4Event):void{
var folder:IMAP4Folder = event.result as IMAP4Folder;
trace("NAME=>[" + folder.name + " --> " + folder.nameUTF8 + "]");
if(!folder.noselect){
client.selectMailbox(folder).search(IMAP4Search.dateSentSince("2010/10/01"));
}
}
POINT1
if(!folder.noselect){
}
If the folder’s noselect property is true, you can NOT select mailbox,
POINT2
client.selectMailbox(folder).search(IMAP4Search.dateSentSince("2010/10/01"));
If you want to get ALL messages from the folder,
client.selectMailbox(folder).search(IMAP4Search.ALL);
If you know the folder name ( ex “INBOX” ) and want to get ALL messages form the folder,
you don’t need to get folder list, so you can change main flow source as following below..
:
client.login();
// client.lsubBlocking();
client.selectMailbox("INBOX").search(IMAP4Search.ALL);
client.logout();
Implemantation of message get handler
// result for search method
private function uidList(event:IMAP4ListEvent):void{
for(var i:int = 0; i<event.length; i++){
var id:String = event.getValue(i);
client.message(id);
}
}
private function handleMessage(event:IMessageEvent):void{
var msg:MimeMessage = event.getMimeMessage();
trace("SUBJECT : " + msg.subjectUTF8);
}
IMessageEvent does not depends on IMAP4 API.
So you can handle the object like as POP3 API.
If you want to know how to get e-mail message.
Please refer to HERE.
private function messageHandler(e:POP3MessageEvent):void{
var msg:MimeMessage = e.getMimeMessage();
// attachmentChildren are only parts has attachments files.
// Don't need to check all children to extract files
var attaches:Array = msg.attachmentChildren;
if(attaches.length > 0){
for each(var attach:MimeBodyPart in attaches){
if(attach is MimeBinaryPart){
var binPart:MimeBinaryPart = attach as MimeImagePart;
var bytes:ByteArray = attach.bodyByteArray;
// v0.5 and less than r69 version has BUG !!
// binPart.getHeader("Content-Disposition"); is both available
var contentDisposition:MimeHeader = binPart.contentDisposition;
if(contentDisposition){
var filename:String = contentDisposition.getParameter("filename");
filename = MimeUtils.decodeMimeHeader(filename);
log.debug("Filename => " + filename );
// save Desktop directory, plese change following codes as you like
var file:File = File.desktopDirectory.resolvePath(filename);
var fs:FileStream = new FileStream();
fs.open(file,FileMode.APPEND);
fs.writeBytes(bytes);
fs.close();
}
}
}
}
}
AIR1.5
Additional requirements
as3crypto library
import com.coltware.airxmail.INetAddress;
import com.coltware.airxmail.MailSender.SMTPSender;
import com.coltware.airxmail.MimeMessage;
import com.coltware.airxmail.RecipientType;
// (Option) If you use TLSSocket
import com.hurlant.crypto.tls.TLSSocket;
private function send_plain_email():void{
// How to send plain text email
var sender:SMTPSender = new SMTPSender();
sender.setParameter(SMTPSender.HOST,"smtp.gmail.com");
sender.setParameter(SMTPSender.PORT,465); // default port is 25
// If you use SMTP-AUTH
sender.setParameter(SMTPSender.AUTH,true);
sender.setParameter(SMTPSender.USERNAME,"username");
sender.setParameter(SMTPSender.PASSWORD,"password");
// If you use TLS/SSL
// you can get as3crypto at http://code.google.com/p/as3crypto/
var tlssocket:TLSSocket = new TLSSocket();
sender.setParameter(SMTPSender.SOCKET_OBJECT,tlssocket);
// Create email message
var message:MimeMessage = new MimeMessage();
// Set from email address and reciepients
var from:INetAddress = new INetAddress("from-email-address@xxxx.yyyy","from label");
message.setFrom(from);
var toRecpt:INetAddress = new INetAddress("to-email-address@xxxx.yyyy","to label");
message.addRcpt(RecipientType.TO,toRecpt);
var ccRecpt:INetAddress = new INetAddress("cc-email-address@xxxx.yyyy","cc label");
message.addRcpt(RecipientType.CC,ccRecpt);
//
message.setSubject("hello world");
message.setTextBody("welcom !! \r\n this is first email. ");
sender.send(message);
sender.close();
}
Point
import com.hurlant.crypto.tls.TLSSocket; : var tlssocket:TLSSocket = new TLSSocket(); sender.setParameter(SMTPSender.SOCKET_OBJECT,tlssocket); :
AIR2
Additional requirements
None
Point
import flash.net.SecureSocket; : sender.setParameter(SMTPSender.SOCKET_OBJECT,new SecureSocket()); :
The last time I introduced the features of “Airxzip”, this post says one of the features.
Change file system and set filemode and directory mode
var writer:ZipFileWriter = new ZipFileWriter(ZipFileWriter.HOST_UNIX);
writer.open(File.desktopDirectory.resolvePath("airxzip_unix.zip"));
writer.setDirMode("0700");
writer.setFileMode("0700");
writer.addDirectory("Foo1");
writer.addFile(File.desktopDirectory.resolvePath("image.jpg"),"Foo2/image.jpg");
writer.setFileMode("0766");
writer.addFile(File.desktopDirectory.resolvePath("image.jpg"),"Foo3/image.jpg");
writer.close();
unzip -Z airxzip_unix.zip Archive: airxzip_unix.zip 1550668 bytes 3 files drwx------ 1.0 unx 0 b- stor 6-May-10 20:11 Foo1/ -rwx------ 2.0 unx 777835 b- defN 14-Jul-09 14:32 Foo2/image.jpg -rwxrw-rw- 2.0 unx 777835 b- defN 14-Jul-09 14:32 Foo3/image.jpg
Default filetype is “ZipFileWriter.HOST_WIN”.
So If you want to create zip file for Mac or Unix/Linux , Please set “ZipFileWriter.HOST_UNIX”.
var writer:ZipFileWriter = new ZipFileWriter(ZipFileWriter.HOST_UNIX);
Default file system
unzip -Z async_airxzip.zip Archive: async_airxzip.zip 775492 bytes 3 files -rw-a-- 2.0 fat 6 b- defN 6-May-10 20:12 sample.txt drwx--- 1.0 fat 0 b- stor 6-May-10 20:12 Foo1/ -rw-a-- 2.0 fat 777835 b- defN 14-Jul-09 14:32 Foo1/image.jpg

