source: Main/src/test_lib/context.cpp @ 27

Revision 27, 1.5 KB checked in by duggan, 18 months ago (diff)

Added test client. When server is running, client makes dummy request for context. Server returns dummy contextid.

Line 
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
11using namespace std;
12
13// TODO: add parameters like width, height, team id, workspace, etc
14uint32
15CreateContext()
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
40uint32
41SwitchContext(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
57uint32
58DeleteContext(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}
Note: See TracBrowser for help on using the repository browser.