CpEpEngine.h
branchExperimental_Callback_Events
changeset 84 ec2e6174b307
parent 83 9b7371990473
child 150 316269fc987e
child 151 432c35b5903c
     1.1 --- a/CpEpEngine.h	Wed May 25 13:04:50 2016 +0200
     1.2 +++ b/CpEpEngine.h	Thu May 26 00:11:36 2016 +0200
     1.3 @@ -107,6 +107,34 @@
     1.4          return session(this);
     1.5      }
     1.6  
     1.7 +	class callbacks
     1.8 +	{
     1.9 +	private:
    1.10 +		CpEpEngine *me;
    1.11 +
    1.12 +	public:
    1.13 +		callbacks(CpEpEngine *myself)
    1.14 +		{
    1.15 +			me = myself;
    1.16 +			me->callback_mutex.lock();
    1.17 +		}
    1.18 +
    1.19 +		~callbacks()
    1.20 +		{
    1.21 +			me->callback_mutex.unlock();
    1.22 +		}
    1.23 +
    1.24 +		operator vector<IpEpEngineCallbacks *>& ()
    1.25 +		{
    1.26 +			return me->callback_vector;
    1.27 +		}
    1.28 +	};
    1.29 +
    1.30 +	callbacks get_callbacks()
    1.31 +	{
    1.32 +		return callbacks(this);
    1.33 +	}
    1.34 +
    1.35      typedef locked_queue<pEp_identity_cpp> identity_queue_t;
    1.36      static ::pEp_identity * retrieve_next_identity(void *management);
    1.37      static PEP_STATUS messageToSend(void *obj, const message *msg);
    1.38 @@ -130,6 +158,9 @@
    1.39      thread *keymanagement_thread;
    1.40      bool verbose_mode;
    1.41  
    1.42 +	mutex callback_mutex;
    1.43 +	vector<IpEpEngineCallbacks*> callback_vector;
    1.44 +
    1.45  public:
    1.46      // runtime config of the adapter
    1.47  
    1.48 @@ -190,6 +221,19 @@
    1.49      STDMETHOD(outgoing_message_color)(text_message *msg, pEp_color * pVal);
    1.50      STDMETHOD(identity_color)(pEp_identity_s * ident, pEp_color * pVal);
    1.51  
    1.52 +	// Event callbacks
    1.53 +
    1.54 +	STDMETHOD(register_callbacks)(IpEpEngineCallbacks *new_callback);
    1.55 +	STDMETHOD(unregister_callbacks)(IpEpEngineCallbacks *obsolete_callback);
    1.56 +
    1.57 +protected:
    1.58 +	HRESULT Fire_MessageToSend(
    1.59 +		/* [in] */ struct text_message *msg);
    1.60 +
    1.61 +	HRESULT Fire_ShowHandshake(
    1.62 +		/* [in] */ struct pEp_identity_s *self,
    1.63 +		/* [in] */ struct pEp_identity_s *partner,
    1.64 +		/* [retval][out] */ sync_handshake_result_s *result);
    1.65  };
    1.66  
    1.67  OBJECT_ENTRY_AUTO(__uuidof(pEpEngine), CpEpEngine)