Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa644ffe authored by San Mehat's avatar San Mehat
Browse files

libsysutils: Add multiple client support and fix some bugs

parent 1441e769
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
#ifndef _FRAMEWORK_CLIENT_H
#define _FRAMEWORK_CLIENT_H

#include "../../../frameworks/base/include/utils/List.h"

#include <pthread.h>

class FrameworkClient {
    int             mSocket;
    pthread_mutex_t mWriteMutex;

public:
    FrameworkClient(int sock);
    virtual ~FrameworkClient() {}

    int sendMsg(char *msg);
    int sendMsg(char *msg, char *data);
};

typedef android::List<FrameworkClient *> FrameworkClientCollection;
#endif
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include "../../../frameworks/base/include/utils/List.h"

class SocketClient;

class FrameworkCommand { 
private:
@@ -28,7 +29,7 @@ public:
    FrameworkCommand(const char *cmd);
    virtual ~FrameworkCommand() { }

    virtual int runCommand(char *data);
    virtual int runCommand(SocketClient *c, char *data) = 0;

    const char *getCommand() { return mCommand; }
};
+4 −2
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include "SocketListener.h"
#include "FrameworkCommand.h"

class SocketClient;

class FrameworkListener : public SocketListener {
private:
    FrameworkCommandCollection *mCommands;
@@ -29,9 +31,9 @@ public:

protected:
    void registerCmd(FrameworkCommand *cmd);
    virtual bool onDataAvailable(int socket);
    virtual bool onDataAvailable(SocketClient *c);

private:
    void dispatchCommand(char *cmd);
    void dispatchCommand(SocketClient *c, char *cmd);
};
#endif
+0 −40
Original line number Diff line number Diff line
/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef _FRAMEWORKMANAGER_H
#define _FRAMEWORKMANAGER_H

#include <pthread.h>

class FrameworkListener;

class FrameworkManager {
    int mDoorbell;        // Socket used to accept connections from framework
    int mFwSock;          // Socket used to communicate with framework
    const char *mSocketName;

    FrameworkListener *mListener;
    
    pthread_mutex_t mWriteMutex;

public:
    FrameworkManager(FrameworkListener *Listener);
    virtual ~FrameworkManager() {}

    int run();
    int sendMsg(char *msg);
    int sendMsg(char *msg, char *data);
};
#endif
+1 −1
Original line number Diff line number Diff line
@@ -27,6 +27,6 @@ public:
    NetlinkListener(int socket);
    virtual ~NetlinkListener() {}
protected:
    virtual bool onDataAvailable(int socket);
    virtual bool onDataAvailable(SocketClient *cli);
};
#endif
Loading