Mobile Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreMobile Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 21st, 2007, 06:22 PM
lukas2me lukas2me is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 3 lukas2me User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 54 sec
Reputation Power: 0
Deploying Midlets mechanism problem

1 ------ THE LINK -----

My client gets the link (for example):

(URL address blocked: See forum rules)

2 ------ THE .HTACCESS FILE and MIME-TYPES -------

I defined needed mime-type on my apache server:

application/java-archive jar
text/vnd.sun.j2me.app-descriptor jad

In the main directory of wap.website.com it is
.htaccess file with specified rewrite rule:

RewriteEngine on
RewriteRule ^x([a-z0-9]+)/([a-z]+)\.jad$ dd.php?c=$1&f=$2 [NC]

This rule rewrites this link:
(URL address blocked: See forum rules)
to this:
(URL address blocked: See forum rules)=CODE&file=MidletName

3 ------- THE PHP SCRIPT ---------

This is the most important fragments of php script (dd.php), which is responsible for validating code and (if successfull) sending (redirecting to) Midlets to the client wap browser:

$download_directory = '(URL address blocked: See forum rules);

// Basic redirecting if there is no code or file specified:
if(!empty($_GET[c]))
{$code = strip_tags($_GET[c]);}else{header('Location: wap.wkomorce.pl');}

if(!empty($_GET[f]))
{$file = strip_tags($_GET[f]);$file=strtolower($file);}else{header('Location: wap.wkomorce.pl');}

///////////////////////////////////////////////
Here is the main body of validating code, connecting to code database, etc.... this works fine.
After successfully validating it calls download() function and sets some special ACCESSED flag to deny next using of this link (one try access). download() function is defined below (2 versions tried):
/////////////////////////////////////////////

// Version 1:
function download()
{
global $file;
global $download_directory;
$location = $download_directory.ucfirst($file).'.jad';
header("Location: $location"); //ends the script
}

// Version 2:
function download(){
global $file;
global $download_directory;
$location = $download_directory.ucfirst($file).'.jad';
header("Content-Type: text/vnd.sun.j2me.app-descriptor");
header("Content-Disposition:inline; filename=".basename($location));
header("Content-length: ".filesize($location));
$sent=readfile($location);
fflush();
}

4 ---------- PROBLEMS!!!!!!!!!!!!! PLEASE HELP -----------

* This all mechanism works fine for quite new mobile phones (on theirs wap browser technically) like for instance Nokia 3220 which has Midp 2.0 and almost every newest ones.

But I still get claims for clients with older phones (obviously still compatible with Midlets they link for).

Examples (just few I remembered):

- Nokia 6280 - unknown file format error
- SE K750i - non-proper application
- Siemens M65 - unknown file format error (or something similar)
- Mototola v3i - no file

And much more ... but the thing is when I handy prepare emergency link by creating temporary folder temp and put Midlet in it and send link:

(URL address blocked: See forum rules)e/temporary_folder/MidletName.jad

to clients with mentioned phones - then everything works Ok and problems dissapears.

That means there is no problem with Midlet's compatibility but with redirecting mechamism, which doesn't works for some kinds of mobile wap browsers?

Anybody can advise me what is going on? I suspect some headers problems but I lost patient to this cos it's imposible for me to try checking it for every model.

I'm sure somebody here knows the answer.
I'll be very gratefull for help.
regards

Reply With Quote
  #2  
Old March 22nd, 2007, 10:52 PM
andymoo's Avatar
andymoo andymoo is offline
Timelord
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Loughborough, Leicestershire
Posts: 605 andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 5 h 53 m 46 sec
Reputation Power: 63
argh dealing with java games, i hate having to do that. too many makes and models, jads and jars....... it gives me a headache.

you know the only thing i can think of from glancing at the code is most likely going to be something dead trivial like new line characters at the end of the content disposition headers. \n\r\n type stuff.

closer inspections sees fflush with two fs, that's going to cause an error you won't see if the headers have been sent and the jar is being deployed.

it could be that which is making it screw on old models.
__________________
Andy Moore << oh no it's got a blog.....
Word Press WAP Plugin with Ad Mob Advertising revenue
PHP developer
deploying ringtones, mp3 downloads and realtones
I'm a geek who's obsessed with stats and gadgets

Reply With Quote
  #3  
Old March 22nd, 2007, 10:57 PM
andymoo's Avatar
andymoo andymoo is offline
Timelord
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Loughborough, Leicestershire
Posts: 605 andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 5 h 53 m 46 sec
Reputation Power: 63
just found this post on devshed

aint search a wonderful think lol kinda backs up my thoughts bout \n\n stuff.......

Reply With Quote
  #4  
Old March 23rd, 2007, 05:35 AM
lukas2me lukas2me is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 3 lukas2me User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 54 sec
Reputation Power: 0
First of all - great thx for answer.
OK - I've change it and cut some download code to be shorter. I found it at some other post where was written that just 2 lines of code is enough. I combined it wiht your advice and know it looks like that:

$location = $download_directory.ucfirst($file).'.jad';
header("Content-Type: text/vnd.sun.j2me.app-descriptor\n\n");
header("Content-Disposition: filename=".basename($_REQUEST[$location]));

Would this 2 headers be enought?
Thanks you for your suggestions. I would never find out it myself.

BTW - do not I need this others headers?:
header("Content-length: ".filesize($location));
$sent=readfile($location);
fflush();

What are they for?
I'm asking cos I just know the basics of Php and I found this fragment of code on the net.
Thx one more time for answer - it is a first forum somebody had any suggestion for my problem.

Reply With Quote
  #5  
Old March 25th, 2007, 10:40 AM
andymoo's Avatar
andymoo andymoo is offline
Timelord
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Loughborough, Leicestershire
Posts: 605 andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 5 h 53 m 46 sec
Reputation Power: 63
Quote:
Originally Posted by lukas2me
$location = $download_directory.ucfirst($file).'.jad';
header("Content-Type: text/vnd.sun.j2me.app-descriptor\n\n");
header("Content-Disposition: filename=".basename($_REQUEST[$location]));

Would this 2 headers be enought?

No, you need more than that, all that would do is set the header with the content type and the header with the content-disposition to force the file to download. It wouldn't do anything else, like send the file which is what it's all about.
Quote:
Originally Posted by lukas2me
BTW - do not I need this others headers?:
header("Content-length: ".filesize($location));
$sent=readfile($location);
fflush();

Thx one more time for answer - it is a first forum somebody had any suggestion for my problem.


You most certainly need those extra lines, just setting a file type and telling it to download the file isn't enough, those lines get the size of the file so that can be sent as a header, that way the device knows how large the download is and can show a progress bar if the device supports it.

The $sent value and readfile are more important than the file size, a download will most likely be okay without a file size header but the readfile is the key to this.

Check out www.php.net/readfile for more info on how it does it, also readfile could be replaced with file_get_contents which would do almost the same job.

As for the answers, you're welcome. I know what a bitch it can be working with java games, just the number of files and supported devices makes it a headache I'd personally prefer to stay away from. Much respect to those who can make a living deploying midlets.

Reply With Quote
  #6  
Old March 30th, 2007, 04:19 AM
lukas2me lukas2me is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 3 lukas2me User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 54 sec
Reputation Power: 0
Hi!
If just anybody still looks here...
This solution haven't made the things better!
Snippet of code I use now to download is:

$location = $download_directory.$file.'.jad';
header("Content-Type: text/vnd.sun.j2me.app-descriptor\n\n");
header("Content-Disposition: filename=".basename($_REQUEST[$location]));
header("Content-length: ".filesize($location));
$sent=readfile($location);

And this makes the Nokia 6280 (!!!) error unsupported format.... or something similar
But this phone is f¤¤ing nice!

Please! AM I something misisng here? Cos I m going crazy

Reply With Quote
  #7  
Old March 30th, 2007, 11:03 AM
andymoo's Avatar
andymoo andymoo is offline
Timelord
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Loughborough, Leicestershire
Posts: 605 andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 5 h 53 m 46 sec
Reputation Power: 63
i'd bet a beer on it being \n\r\n type stuff at the end of the content disposition header.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreMobile Programming > Deploying Midlets mechanism problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway