| 1 | /* |
|---|
| 2 | * Copyright 2011 Dewey Taylor (james.dewey.taylor@gmail.com) |
|---|
| 3 | * All rights reserved. Distributed under the terms of the MIT license. |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #include "Drafter.h" |
|---|
| 7 | #include "DrafterPrivateDefs.h" |
|---|
| 8 | |
|---|
| 9 | #include <iostream> |
|---|
| 10 | |
|---|
| 11 | using namespace std; |
|---|
| 12 | |
|---|
| 13 | // TODO: add parameters like width, height, team id, workspace, etc |
|---|
| 14 | uint32 |
|---|
| 15 | CreateContext() |
|---|
| 16 | { |
|---|
| 17 | // get a messenger for the gfx_server |
|---|
| 18 | status_t error; |
|---|
| 19 | if (server_msgr == NULL) |
|---|
| 20 | { |
|---|
| 21 | server_msgr = new BMessenger("application/x-vnd.Drafter-gfx-server", -1, &error); |
|---|
| 22 | if (error != B_OK) |
|---|
| 23 | { |
|---|
| 24 | return 0xdeadbeef; |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | // TODO: send a request for a new context |
|---|
| 28 | BMessage request(D_CREATE_CONTEXT); |
|---|
| 29 | BMessage reply; |
|---|
| 30 | //BMessage* reply = new BMessage(D_REPLY); |
|---|
| 31 | server_msgr->SendMessage(&request, &reply); |
|---|
| 32 | |
|---|
| 33 | // TODO: retrieve the resuls |
|---|
| 34 | uint32 contextnum; |
|---|
| 35 | reply.FindInt32("contextid", 0, &((int32)contextnum)); |
|---|
| 36 | cout<<"Context returned: "<< contextnum << endl; |
|---|
| 37 | return contextnum; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | uint32 |
|---|
| 41 | SwitchContext(uint32 context) |
|---|
| 42 | { |
|---|
| 43 | /* |
|---|
| 44 | if (context < DRAFTER_MAX_CONTEXTS) |
|---|
| 45 | { |
|---|
| 46 | if (contexts[context].flags & DRAFTER_CONTEXT_USED) |
|---|
| 47 | { |
|---|
| 48 | // how do we specify the current context? local variable in the app? |
|---|
| 49 | current_context = context; |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | return D_ERR_BAD_CONTEXT_ID; |
|---|
| 53 | */ |
|---|
| 54 | return 0; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | uint32 |
|---|
| 58 | DeleteContext(uint32 context) |
|---|
| 59 | { |
|---|
| 60 | // TODO: add locking |
|---|
| 61 | // TODO: check the teamID too |
|---|
| 62 | /* if (context < DRAFTER_MAX_CONTEXTS) |
|---|
| 63 | { |
|---|
| 64 | if (contexts[context].flags & DRAFTER_CONTEXT_USED) |
|---|
| 65 | { |
|---|
| 66 | contexts[context].flags &= 0xFFFFFFFF - DRAFTER_CONTEXT_USED; |
|---|
| 67 | return D_OK; |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | return D_ERR_BAD_CONTEXT_ID; |
|---|
| 71 | */ |
|---|
| 72 | return 0; |
|---|
| 73 | } |
|---|