21 #ifndef G_SMTP_CLIENT_PTR_H
22 #define G_SMTP_CLIENT_PTR_H
59 template <
typename TClient>
63 G_EXCEPTION( InvalidState ,
"invalid state of smtp client" ) ;
65 explicit ClientPtr( TClient * p = NULL ,
bool preserve_resolver_info =
false ) ;
74 void reset( TClient * p = NULL ) ;
117 void doneSlot( std::string ,
bool ) ;
118 void eventSlot( std::string , std::string ) ;
119 void connectedSlot() ;
120 void connectSignalsToSlots() ;
121 void disconnectSignals() ;
132 template <
typename TClient>
136 m_resolver_info(std::string(),std::string())
142 m_resolver_info = m_p->resolverInfo() ;
144 connectSignalsToSlots() ;
153 template <
typename TClient>
158 disconnectSignals() ;
159 m_p->doDelete(std::string()) ;
163 template <
typename TClient>
168 disconnectSignals() ;
173 template <
typename TClient>
178 disconnectSignals() ;
181 p->doDeleteForExit() ;
185 template <
typename TClient>
191 m_p->eventSignal().connect(
G::slot(*
this,&ClientPtr::eventSlot) ) ;
192 m_p->connectedSignal().connect(
G::slot(*
this,&ClientPtr::connectedSlot) ) ;
196 template <
typename TClient>
199 disconnectSignals() ;
201 TClient * old = m_p ;
205 old->doDelete(std::string()) ;
208 if( m_p != NULL && m_update )
210 m_p->updateResolverInfo( m_resolver_info ) ;
213 connectSignalsToSlots() ;
216 template <
typename TClient>
219 return m_done_signal ;
222 template <
typename TClient>
225 return m_event_signal ;
228 template <
typename TClient>
231 return m_connected_signal ;
234 template <
typename TClient>
238 disconnectSignals() ;
240 m_done_signal.emit( reason , retry ) ;
243 template <
typename TClient>
244 void ClientPtr<TClient>::disconnectSignals()
248 m_p->doneSignal().disconnect() ;
249 m_p->eventSignal().disconnect() ;
250 m_p->connectedSignal().disconnect() ;
254 template <
typename TClient>
255 void ClientPtr<TClient>::connectedSlot()
258 m_resolver_info = m_p->resolverInfo() ;
259 m_connected_signal.emit() ;
262 template <
typename TClient>
263 void ClientPtr<TClient>::eventSlot( std::string s1 , std::string s2 )
265 m_event_signal.emit( s1 , s2 ) ;
268 template <
typename TClient>
274 template <
typename TClient>
280 template <
typename TClient>
284 throw InvalidState() ;
288 template <
typename TClient>
292 throw InvalidState() ;
296 template <
typename TClient>
299 return m_resolver_info ;
TClient * get()
Returns the pointer, or NULL if deleted.
void releaseForExit()
Can be called on program termination when there may be no TimerList or EventLoop instances.
G::Signal2< std::string, std::string > & eventSignal()
Returns a signal which indicates something interesting.
Slot0 slot(T &object, void(T::*fn)())
Part of the slot/signal system.
A class that holds a host/service name pair and optionally the results of a name-to-address lookup...
ClientPtr(TClient *p=NULL, bool preserve_resolver_info=false)
Constructor.
void cleanupForExit()
Can be called on program termination when there may be no TimerList or EventLoop instances.
void reset(TClient *p=NULL)
Resets the pointer.
G::Signal2< std::string, bool > & doneSignal()
Returns a signal which indicates that client processing is complete and the client instance has delet...
Part of the slot/signal system.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
A smart pointer class for GNet::HeapClient.
G::Signal0 & connectedSignal()
Returns a signal which indicates that the connection has been established successfully.
TClient * operator->()
Returns the pointer. Throws if deleted.
ResolverInfo resolverInfo() const
Returns the current or last client's ResolverInfo.
void connect(Slot2< P1, P2 > slot)
bool busy() const
Returns true if the pointer is not NULL.