Added Gtest for smartcard-service
[platform/core/connectivity/smartcard-service.git] / server / include / ClientInstance.h
index 368ca37..7cef69d 100644 (file)
@@ -1,19 +1,18 @@
 /*
-* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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.
-*/
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 CLIENTINSTANCE_H_
 #define CLIENTINSTANCE_H_
 /* standard library header */
 #include <map>
 #include <vector>
-#if 1
-#include <glib.h>
-#endif
+#include <string>
 
 /* SLP library header */
 
 /* local header */
-#include "Message.h"
 #include "ServiceInstance.h"
 
 namespace smartcard_service_api
 {
+       /* LCOV_EXCL_START */
        class ClientInstance
        {
-       private:
-               void *ioChannel;
-               int socket;
-               int watchID;
-               int state;
-               int pid;
+       private :
+               string name;
+               pid_t pid;
                vector<ByteArray> certHashes;
                map<unsigned int, ServiceInstance *> mapServices;
 
-               static gboolean _getCertificationHashes(gpointer user_data);
-
-       public:
-               ClientInstance(void *ioChannel, int socket, int watchID, int state, int pid)
+       public :
+               ClientInstance(const char *name, pid_t pid) :
+                       name(name), pid(pid)
                {
-                       this->ioChannel = ioChannel;
-                       this->socket = socket;
-                       this->watchID = watchID;
-                       this->state = state;
-                       this->pid = pid;
                }
-               ~ClientInstance() { removeServices(); }
-
-               inline bool operator ==(const int &socket) const { return (this->socket == socket); }
-
-               inline void *getIOChannel() { return ioChannel; }
-               inline int getSocket() { return socket; }
-               inline int getWatchID() { return watchID; }
-               inline int getState() { return state; }
+               inline ~ClientInstance() { removeServices(); }
+               inline bool operator ==(const char *name) const { return (this->name.compare(name) == 0); }
 
-               void setPID(int pid);
-               inline int getPID() { return pid; }
+               inline void setPID(int pid) { this->pid = pid; }
+               inline int getPID() const { return pid; }
 
-               bool createService(unsigned int context);
-               ServiceInstance *getService(unsigned int context);
-               void removeService(unsigned int context);
+               ServiceInstance *createService();
+               ServiceInstance *getService(unsigned int handle);
+               void removeService(unsigned int handle);
                void removeServices();
-
-               bool sendMessageToAllServices(int socket, Message &msg);
+               inline size_t getServiceCounts() const { return mapServices.size(); }
                void generateCertificationHashes();
 
                inline vector<ByteArray> &getCertificationHashes() { return certHashes; }
-
-               friend gboolean _getCertificationHashes(gpointer user_data);
        };
+       /* LCOV_EXCL_STOP */
 } /* namespace smartcard_service_api */
+
 #endif /* CLIENTINSTANCE_H_ */