static PyObject *PyFFFont_CollabSessionJoin(PyFF_Font *self, PyObject *args) { #ifdef BUILD_COLLAB char* address = collabclient_makeAddressString( "localhost", collabclient_getDefaultBasePort()); if ( PySequence_Size(args) == 1 ) { char* uaddr = 0; if ( !PyArg_ParseTuple(args,"es","UTF-8",&uaddr) ) return( NULL ); address = uaddr; } FontViewBase *fv = self->fv; TRACE("PyFFFont_CollabSessionJoin() address:%s fv:%p\n", address, self->fv ); void* cc = collabclient_newFromPackedAddress( address ); TRACE("PyFFFont_CollabSessionJoin() address:%s cc1:%p\n", address, cc ); fv->collabClient = cc; TRACE("PyFFFont_CollabSessionJoin() address:%s cc2:%p\n", address, fv->collabClient ); FontViewBase* newfv = collabclient_sessionJoin( cc, (FontView*)fv ); // here fv->collabClient is 0 and there is a new fontview. TRACE("PyFFFont_CollabSessionJoin() address:%s cc3:%p\n", address, fv->collabClient ); TRACE("PyFFFont_CollabSessionJoin() address:%s cc4:%p\n", address, newfv->collabClient ); inPythonStartedCollabSession = 1; PyObject* ret = PyFV_From_FV_I( newfv ); Py_RETURN( ret ); #endif Py_RETURN( self ); }
static PyObject *PyFFFont_CollabSessionRunMainLoop(PyFF_Font *self, PyObject *args) { #ifdef BUILD_COLLAB int timeoutMS = 1000; int iterationTime = 50; int64_t originalSeq = collabclient_getCurrentSequenceNumber( self->fv->collabClient ); TRACE("PyFFFont_CollabSessionRunMainLoop() called fv:%p\n", self->fv ); TRACE("PyFFFont_CollabSessionRunMainLoop() called cc:%p\n", self->fv->collabClient ); for( ; timeoutMS > 0; timeoutMS -= iterationTime ) { g_usleep( iterationTime * 1000 ); MacServiceReadFDs(); } TRACE("originalSeq:%ld\n",(long int)(originalSeq)); TRACE(" newSeq:%ld\n",(long int)(collabclient_getCurrentSequenceNumber( self->fv->collabClient ))); if( originalSeq < collabclient_getCurrentSequenceNumber( self->fv->collabClient )) { printf("***********************\n"); printf("*********************** calling python updated function!!\n"); printf("***********************\n"); printf("***********************\n"); InvokeCollabSessionSetUpdatedCallback( self ); } #endif Py_RETURN( self ); }
static PyObject *PyFFFont_CollabSessionStart(PyFF_Font *self, PyObject *args) { #ifdef BUILD_COLLAB int port_default = collabclient_getDefaultBasePort(); int port = port_default; char address[IPADDRESS_STRING_LENGTH_T]; if( !getNetworkAddress( address )) { snprintf( address, IPADDRESS_STRING_LENGTH_T-1, "%s", HostPortPack( "127.0.0.1", port )); } else { snprintf( address, IPADDRESS_STRING_LENGTH_T-1, "%s", HostPortPack( address, port )); } if ( PySequence_Size(args) == 1 ) { char* uaddr = 0; if ( !PyArg_ParseTuple(args,"es","UTF-8",&uaddr) ) return( NULL ); strcpy( address, uaddr ); } FontViewBase *fv = self->fv; HostPortUnpack( address, &port, port_default ); printf("address:%s\n", address ); printf("port:%d\n", port ); void* cc = collabclient_new( address, port ); fv->collabClient = cc; collabclient_sessionStart( cc, (FontView*)fv ); printf("connecting to server...sent the sfd for session start.\n"); inPythonStartedCollabSession = 1; #endif Py_RETURN( self ); }
/** \ingroup python_interface_edge * \brief Rich comparison of an edge with another */ PyObject* igraphmodule_Edge_richcompare(igraphmodule_EdgeObject *a, PyObject *b, int op) { igraphmodule_EdgeObject* self = a; igraphmodule_EdgeObject* other; if (!igraphmodule_Edge_Check(b)) Py_RETURN_NOTIMPLEMENTED; other = (igraphmodule_EdgeObject*)b; if (self->gref != other->gref) Py_RETURN_FALSE; switch (op) { case Py_EQ: Py_RETURN(self->idx == other->idx); case Py_NE: Py_RETURN(self->idx != other->idx); case Py_LE: Py_RETURN(self->idx <= other->idx); case Py_LT: Py_RETURN(self->idx < other->idx); case Py_GE: Py_RETURN(self->idx >= other->idx); case Py_GT: Py_RETURN(self->idx > other->idx); default: Py_RETURN_NOTIMPLEMENTED; } }