Saturday, 17 February 2007

3 weeks in holland

I had been to Holland for 3 weeks for a mobile project that will go live in the next weeks. My lips are tied :) but i am planning to publish a detailed tutorial of the project in netbeans.org and java.sun.com . I am working on the tutorial and trying to get it ready for the review.

and here are some guys dressed-up for the south holland festival, not only these guys all the south holland were dressed-up like that from 7 to 77.

Friday, 16 February 2007

adding contact in msnp 13

in msnp13, you have to send the ADL and RML commands too, besides the SOAP requests to add/block/remove contact. Because SOAP requests saves your changes to the permanent addres book, but ADL and RML make changes in your current session to notify the target contac

for blocking xxxx@hotmail.com, you have to send the following codes.



<< ADL 0 62
<ml><d n=”hotmail.com”><c n=”xxxx” l=”4″ t=”1″ /></d></ml>
>>ADL 0 OK
<< RML 1 62
<ml><d n=”hotmail.com”><c n=”xxxx” t=”1″ l=”2″ /></d></ml>
>>RML 1 OK

advanced session management

In servlets, you really have a good control over the sessions. Forexample, here is a sample code from one of my server-client project;

To set the timeout to 1 minute and register the client;
session.setMaxInactiveInterval(60);
session.setAttribute("user",new Client(userID));


To get the same client with every of its request;
Client client=(Client) session.getAttribute("user");
int userID client.userID;


And here is our client class;

public class Client implements HttpSessionBindingListener {
public int userID;
public Client(int
userIDTMP) {
userID = userIDTMP;
}
public void valueBound(HttpSessionBindingEvent event) {
//Client Connected
userConnected(userID);
}
public void valueUnbound(HttpSessionBindingEvent event) {
//Client disconnected
//Session expired or invalidated by the servlet.
userDisconnected(userID)
}
}

canvas keycodes

Canvas keyCodes for some phones.

//nokia, samsung, sony ericsson
static int keyFire = -5;
static int keyMenu = -6;
static int keyCancel = -7;
static int keyLeft = -3;
static int keyRight = -4;
static int keyUp = -1;
static int keyDown = -2;

//sagem (myX5-2)
static int keyFire = -5;
static int keyMenu = -7;
static int keyCancel = -6;
static int keyLeft = -3;
static int keyRight = -4;
static int keyUp = -1;
static int keyDown = -2;

//motorola (v3)
static int keyFire = -20;
static int keyMenu = -21;
static int keyCancel = -22;
static int keyLeft = -2;
static int keyRight = -5;
static int keyUp = -1;
static int keyDown = -6;

proxy in your java applications



//Proxy port
String port="";

//Proxy host
String host="";

System.getProperties().put("proxySet","true");
System.getProperties().put("proxyPort",port);
System.getProperties().put("proxyHost",host);

xml string fixer

If you encounter the following error;

"The entity name must immediately follow the ‘&’ in the entity reference"

you may filter the string, which you want to convert to xml document, with the following code.


private String xmlFixer(String xmlString) {
xmlString = xmlString.replaceAll("&([^; ]*);", "||VALIDXMLTAG||$1;");
xmlString = xmlString.replaceAll("&","&amp;");
xmlString = xmlString.replaceAll("\\|\\|VALIDXMLTAG\\|\\|([^; ]*);", "&$1;");
return (xmlString);
}

Thursday, 15 February 2007

nokia 3650 : “file is corrupted”

in nokia 3650, if you face "file is corrupted" error, while you are downloading an application with OTA, you can fix that issue by putting a midlet icon parameter to the jad file.

Example:

...
MIDlet-Icon: /res/icon2.png
...