static void collabclient_sendRedo_Internal( FontViewBase *fv, SplineChar *sc, Undoes *undo, int isLocalUndo ) { printf("collabclient_sendRedo_Internal()\n"); cloneclient_t* cc = fv->collabClient; if( !cc ) return; char* uuid = fv->sf->xuid; printf("uuid:%s\n", uuid ); printf("________________________ WRITE undo.layer: %d layer_sz:%d\n", undo->layer, sc->layer_cnt ); int idx = 0; char filename[PATH_MAX]; snprintf(filename, PATH_MAX, "%s/fontforge-collab-x.sfd", getTempDir() ); FILE* f = fopen( filename, "wb" ); SFDDumpUndo( f, sc, undo, "Undo", idx ); fclose(f); printf("wrote undo sfd... filename: %s\n", filename ); char* sfd = GFileReadAll( filename ); printf("read undo sfd, data:%p\n", sfd ); if( DEBUG_SHOW_SFD_CHUNKS ) printf("SENDING: %s\n\n", sfd ); printf("timers1...\n" ); cc->roundTripTimerWaitingSeq = cc->publisher_sendseq; BackgroundTimer_touch( cc->roundTripTimer ); printf("timers2...\n" ); printf("sfd:%p...\n", sfd ); kvmsg_t *kvmsg = kvmsg_new(0); kvmsg_fmt_key (kvmsg, "%s%d", SUBTREE, cc->publisher_sendseq++); kvmsg_set_body (kvmsg, sfd, strlen(sfd) ); kvmsg_set_prop (kvmsg, "type", MSG_TYPE_UNDO ); kvmsg_set_prop (kvmsg, "uuid", uuid ); char pos[100]; sprintf(pos, "%d", sc->orig_pos ); printf("pos:%s\n", pos ); printf("sc.name:%s\n", sc->name ); size_t data_size = kvmsg_size (kvmsg); printf("data.size:%ld\n", data_size ); kvmsg_set_prop (kvmsg, "pos", pos ); kvmsg_set_prop (kvmsg, "name", sc->name ); sprintf(pos, "%d", isLocalUndo ); kvmsg_set_prop (kvmsg, "isLocalUndo", pos ); kvmsg_send (kvmsg, cc->publisher); kvmsg_destroy (&kvmsg); DEBUG("Sent a undo chunk of %d bytes to the server\n",strlen(sfd)); free(sfd); }
void collabclient_sessionStart( void* ccvp, FontView *fv ) { #ifdef BUILD_COLLAB cloneclient_t* cc = (cloneclient_t*)ccvp; // // Fire up the fontforge-internal-collab-server process... // { char command_line[PATH_MAX+1]; #if defined(__MINGW32__) sprintf(command_line, "'%s/ffcollab.bat' %d", getGResourceProgramDir(), cc->port ); #else sprintf(command_line, "%s/bin/FontForgeInternal/fontforge-internal-collab-server %d", getLibexecDir_NonWindows(), cc->port ); #endif printf("command_line:%s\n", command_line ); GError * error = 0; if(!getenv("FONTFORGE_USE_EXISTING_SERVER")) { int rc = g_spawn_command_line_async( command_line, &error ); if( !rc ) { fprintf(stderr, "Error starting collab server\n"); if( error ) fprintf(stderr, "code:%d message:%s\n", error->code, error->message ); } } } printf("Starting a session, sending it the current SFD as a baseline...\n"); if( !ff_uuid_isValid( fv->b.sf->collab_uuid)) ff_uuid_generate( fv->b.sf->collab_uuid ); strcpy( cc->unacknowledged_beacon_uuid, fv->b.sf->collab_uuid ); time( &cc->unacknowledged_beacon_sendTime ); int s2d = 0; char filename[PATH_MAX]; snprintf(filename, PATH_MAX, "%s/fontforge-collab-start-%d.sfd", getTempDir(), getpid()); int ok = SFDWrite(filename,fv->b.sf,fv->b.map,fv->b.normal,s2d); printf("connecting to server...3 ok:%d\n",ok); if ( ok ) { char* sfd = GFileReadAll( filename ); printf("connecting to server...4 sfd:%p\n", sfd ); collabclient_sendSFD( cc, sfd, fv->b.sf->collab_uuid, fv->b.sf->fontname ); } GFileUnlink(filename); printf("connecting to server...sent the sfd for session start.\n"); fv->b.collabState = cs_server; FVTitleUpdate( &fv->b ); collabclient_setHaveLocalServer( 1 ); beacon_moon_bounce_timerID = BackgroundTimer_new( 3000, beacon_moon_bounce_timer_callback, cc ); collabclient_notifySessionJoining( cc, (FontViewBase*)fv ); #endif }