How to implement ACTION (move / rename, set permissions) in J2ME Bluetooth OBEX?

The Bluetooth FTP specification says I need to use the ACTION operation, here is the page

But ClentSession provides only GET and PUT operations and is not mentioned in javadocs.

this is how the file creation operation looks, it's pretty simple

    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();
    }

Question 1. How to implement ACTION operation with custom headers to perform move / rename and set permissions? This should be possible without the JSR82 OBEX API. Please help me do this.

Question 2: I figured out how to set permissions? According to OBEX_Errata compiled for 1.3.pdf (thanks alanjmcf!)

1

2

So, to set read-only, I have to do the following:

    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 .

+5
1

, , 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] (), , ACTION!: -,) OBEX- ACTION PUT GET .. AC- 0x86.

"OBEX_Errata Compiled For 1.3.pdf". IrDA , , , (http://www.irda.org). OBEX (1.5 IIRC). , . googling , "move/rename object action", PDF "1.3 Errata".

, Java Opcodes ( GET PUT), HeaderId, .:-( * ( , HeaderId , ).

Java API ClientSession. , OBEX, . ...

+3

All Articles