蓝牙FTP规范说我需要使用动作操作,这是一个页面

但是ClentSession只提供了GET和PUT操作,在javadoc中没有提到。
下面是create file操作的外观,它非常简单
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:如何使用自定义头部实现ACTION操作,进行移动/重命名和权限设置?这在没有JSR82 OBEX API的情况下应该是可能的。请帮我做这件事。
问题2:我是否了解如何设置权限?根据为1.3.pdf编译的OBEX_Errata (感谢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:我如何进行动作操作以及如何设置头部。
发布于 2012-05-03 17:36:34
请注意,您从Bluetooth FTP规范中引用的文本提到了三个头: ActionId、Name、DestName。因此您需要添加一个NAME标头和一个DestName标头。Jsr-82显然没有为这个(新的)头定义const,所以引用OBEX规范:
修改
2.1 OBEX标头
HI identifier | Header name | Description
0x94 Action Id Specifies the action to be performed (used in ACTION operation)
0x15 DestName The destination object name (used in certain ACTION operations)
0xD6 Permissions 4 byte bit mask for setting permissions
0x17 to 0x2F Reserved for future use. This range includes all combinations of the upper 2 bits因此,创建以下代码等(我的Java有点生疏)
static final int DEST_NAME = 0x15;并在你的代码中使用它。
ADD所有作为动作的操作(动作)都使用动作操作!:-,),即使用OBEX操作码操作而不是PUT或GET等。操作码操作的值是0x86。
我从“为1.3.pdf编译的OBEX_Errata”中读到了这篇文章。IrDA确实对规范收费,但现在似乎可以按需提供规范(http://www.irda.org)。索取最新的OBEX规范副本(1.5 IIRC)。我自己也这样做了,但还没有得到回应。或者你可以尝试在谷歌上搜索“移动/重命名对象操作”,以获得'1.3勘误表‘PDF。
无论如何,如果Java阻止你使用新的操作码(只允许GET和PUT),并且也阻止你使用新的HeaderId值,那么你无论如何都不能继续。:-( *(他们没有理由这样做,因为HeaderId会对它包含的数据类型进行编码)。
在再次查看Java API之后,我找不到任何通过ClientSession发送任意命令的方法。您必须手动构建数据包,连接到OBEX服务,然后通过该连接发送和接收数据包。构建包并不是太难……
https://stackoverflow.com/questions/10388994
复制相似问题