Archive for 4月, 2011

Recently, I started developing application on Adobe Android AIR.
But I wonder how I can debug my application on Android Phone.

I searched it, but many solutions can’t fit my case.
My requirements are
1 ) No USB connection
2 ) No Android SDK on my PC.
3 ) Can support on production mode ( No debug player )

In other words, The limitations move to outer enviroment from app and android phone.
And I want to control the outer environment.

My solution

Requirements

1 ) Need syslog server that can support TCP connetcion ( these are “rsyslog” or “syslog-ng” as I know )
2 ) TCPSyslogTarget as3 class ( can download on airxlib_log )
3 ) Wifi connection ( optional )
“optional” means .. I don’t think it is easy to make syslog server on the global network.

setup syslog server

The following config is a part of “rsyslog.conf”.

$ModLoad imtcp.so
$InputTCPServerRun 514
$AllowedSender TCP, 127.0.0.1, 192.168.1.0/24
:
local1.*                                                /var/log/air.log
setup logging functions on your source code
import com.coltware.airxlib.log.TCPSyslogTarget;

//  my syslog server's ip is "192.168.1.5". please change 

var syslog:TCPSyslogTarget = new TCPSyslogTarget("192.168.1.5");
syslog.program = "AdobeAIR";
syslog.filters = ["*"];
syslog.level = LogEventLevel.DEBUG;
syslog.facility = TCPSyslogTarget.LOG_LOCAL1;
syslog.includeCategory = true;
Log.addTarget(syslog);

use flex logging functions.

import mx.logging.ILogger;
import mx.logging.Log;

private static var log:ILogger = Log.getLogger("foofoo");
log.debug("mmmmmm....");

At first, I tried to use UDP connection. But I can’t. ( I don’t know the reason )

Save e-mail to local file
private function handleMessage(event:IMessageEvent):void{

 var msg:MimeMessage = event.getMimeMessage();
 var file:File = File.desktopDirectory.resolvePath("mail_" + msg.messageId + ".eml");

 var fs:FileStream = new FileStream();
 fs.open(file,FileMode.WRITE);
 fs.writeBytes(event.source);
 fs.close();
}
Re-parse and make MimeMessage from local file

The following example is required v0.7 or more.


// var dir:File = File.someDirectoryYouWantToUse

var list:Array = dir.getDirectoryListing();
var length:int = list.length;
for(var i:int = 0; idownload airxmail

I released airxmail version 0.7.

New feature

IMAP4

If you use draft implementation, please change this version.

google code download

You have to care 2 type of content type if you want to get html part of e-mail message.

1 ) text/html
2 ) multipart/alternative

1 ) text/html

In this case, you can get html content very easily.
The mime message only has one body part.

private function handleMessage(event:IMessageEvent):void{
  var msg:MimeMessage = event.getMimeMessage();
  var htmlText:String = msg.bodyText;
}
2 ) multipart/alternative

This case is slightly harder than case 1.
But airxmail support to access to child part using findParts method.

var parts:Array = msg.findParts("text/html");
  if(parts.length > 0){
    var htmlText:String = MimeBodyPart(parts[0]).bodyText;
  }
}

Typically, text/html part is the only one.
So I think you don’t need to check first text/html part.

see source code

MimeMessage.findPart

RSS
Add to Google
2011年4月
« 2月   5月 »
 12
3456789
10111213141516
17181920212223
24252627282930