蓝牙FTP规范说我需要用行动操作,这里有一个页面 http://i47.tinypic.com/2425t2v.png如何在J2ME蓝牙OBEX中实现ACTION(移动/重命名,设置权限)操作?
但ClentSession仅提供get和put操作,并且在javadoc文档只字不提。
这里的创建文件操作的样子,这是很容易
public void create() throws IOException {
HeaderSet hs = cs.createHeaderSet();
hs.setHeader(HeaderSet.NAME, file);
op = cs.put(hs);
OutputStream os = op.openOutputStream();
os.close();
op.close();
}
问题1:如何实现自定义页眉行动操作进行移动/重命名并设置权限?没有JSR82 OBEX API应该是可能的。请帮助我做到这一点。
问题2: 我了解如何设置权限吗? 据OBEX_Errata编译1.3.pdf
1 http://i45.tinypic.com/2h84led.jpg
2 http://i49.tinypic.com/2wgysmx.png
因此,设置只读,我应该做到以下几点(感谢alanjmcf!):
int a = 0;
//byte 0 //zero
//byte 1 //user
//byte 2 //group
//byte 3 //other
//set read for user
a |= (1 << 7); //8th bit - byte 1, bit 0 -> set to 1
// a = 10000000
//for group
a |= (1 << 15); //16th bit - byte 2, bit 0 -> set to 1
// a = 1000000010000000
//for other
a |= (1 << 23); //24th bit - byte 3, bit 0 -> set to 1
// a = 100000001000000010000000
//or simply
private static final int READ = 8421504 //1000,0000,1000,0000,1000,0000
int value = 0 | READ;
//========== calculate write constant =========
a = 0;
a |= (1 << 8); //write user
a |= (1 << 16); //write group
a |= (1 << 24); //write other
// a = 1000000010000000100000000
private static final int WRITE = 16843008 // 1,0000,0001,0000,0001,0000,0000
//========= calculate delete constant ==========
a = 0;
a |= (1 << 9); //delete user
a |= (1 << 17); //delete group
a |= (1 << 25); //delete other
//a = 10000000100000001000000000
private static final DELETE = 33686016; //10,0000,0010,0000,0010,0000,0000
//========= calculate modify constant ==========
a = 0;
a |= (1 << (7 + 7)); //modify user
a |= (1 << (15 + 7)); //modify group
a |= (1 << (23 + 7)); //modify other
//a = 1000000010000000100000000000000
private static final MODIFY = 1077952512; // 100,0000,0100,0000,0100,0000,0000,0000
// now, if i want to set read-write-delete-modify, I will do the following:
int rwdm = 0 | READ | WRITE | DELETE | MODIFY;
// and put the value to the header... am I right?
如果对,唯一的问题仍然是问题1:如何使ACTION操作以及如何设置标题。
+1为所有闪亮的图片! –
http://code.google.com/p/blueframe/source/checkout - 也许有些东西 –
@AmigableClarkKant设备交换自己格式的数据。它无法帮助我创建目标设备将识别为OBEX的标头。 –