int sageDisplayManager::clearDisplay(int instID)
{
	int index;
	pixelDownloader*  temp_app = findApp(instID, index);

   if (temp_app)
	{
      temp_app->enqueConfig(CLEAR_STR);
   }
	else {
		/*
      if (reconfigStr[instID]) {
         sage::printLog("sageDisplayManager::clearDisplay : invalid instance ID");
         return -1;
      }
		*/
		pixelDownloader *dwloader = new pixelDownloader;
		dwloader->instID = instID;
		downloaderList.push_back(dwloader);

		char* str_config = new char[strlen(CLEAR_STR)+1];
      strcpy(str_config, CLEAR_STR);
		reconfigStr.push_back(str_config);
   }
	return 1;
}
Beispiel #2
0
Boolean launchServer (OSType serverid) {
	
	/*
	if the application whose creator id is serverid is running, return true.
	
	if not, we look for the application and try to launch it. we wait until it's 
	actually running and ready to receive Apple Events.
	*/
	
	FSSpec fs;
	
	if (appRunning (serverid))
		return (true);
		
	if (!findApp (serverid, &fs))
		return (false);
		
	if (!launchApp (&fs))
		return (false);
		
	while (!appRunning (serverid)) {
		
		EventRecord ev;
		
		EventAvail (everyEvent, &ev);
		} /*while*/
		
	return (true);
	} /*launchServer*/
Beispiel #3
0
void QuickLauncher::clearTempButtons()
{
    std::set<QuickButton*> allButtons;
    //put all the m_buttons in a set (removes duplicates automatically
    if (m_newButtons) 
    {
        allButtons.insert(m_newButtons->begin(),m_newButtons->end());
    }
    if (m_oldButtons)
    {
        allButtons.insert(m_oldButtons->begin(),m_oldButtons->end());
    }
    if (m_dragButtons)
    {
        allButtons.insert(m_dragButtons->begin(),m_dragButtons->end());
    }
    
    //delete temp ButtonGroups
    delete m_newButtons; m_newButtons=0;
    delete m_oldButtons; m_oldButtons=0;
    delete m_dragButtons; m_dragButtons=0;
    
    //if an element allButtons is NOT in m_buttons (the ones we keep), delete it
    std::set<QuickButton *>::iterator iter = allButtons.begin();
    while (iter != allButtons.end())
    {
        if (findApp(*iter) == NotFound)
        {
            delete *iter;
        }
        ++iter;
    }
    m_dragAccepted = false;
    m_dropPos = NotFound;
}
int sageDisplayManager::updateDisplay(char *msg)
{
   int instID;
   sscanf(msg, "%d", &instID);
   char *updateInfo = sage::tokenSeek(msg, 1);
	int index;
	pixelDownloader* temp_app = findApp(instID, index);

	if (temp_app) {
      temp_app->enqueConfig(updateInfo);
      if (temp_app->getStatus() == PDL_WAIT_CONFIG)
         temp_app->fetchSageBlocks();
   }
   else {
		/*
      if (reconfigStr[index]) {
         sage::printLog("sageDisplayManager::updateDisplay : invalid instance ID");
         return -1;
      }
		*/
		pixelDownloader *dwloader = new pixelDownloader;
		dwloader->instID = instID;
		downloaderList.push_back(dwloader);

		char* str_config = new char[strlen(updateInfo)+1];
      strcpy(str_config, updateInfo);
		reconfigStr.push_back(str_config);
   }

   return 0;
}
Beispiel #5
0
void QuickLauncher::removeAppManually(QuickButton *button)
{
    int index = findApp(button);
    if (index == NotFound)
    {
        return;
    }
    removeApp(index, true);
}
Beispiel #6
0
void QuickLauncher::removeApp(TQString url, bool manuallyRemoved)
{
    int index = findApp(url);
    if (index == NotFound)
    {
        kdDebug() << "removeApp: Not found: " << url << endl;
        return;
    }
    removeApp(index, manuallyRemoved);
}
int sageDisplayManager::shutdownApp(int instID)
{
	//fprintf(stderr, "[%d] SDM::shutdownApp(%d) \n", shared->nodeID, instID);
   bool appShutdown = false;
	pixelDownloader* temp_app= NULL;
	char* temp_str= NULL;

   if (instID == -1) {
      sage::printLog("sageDisplayManager::shutdownApp() : SDM %d is shutting down all applications", shared->nodeID);
		std::vector<pixelDownloader*>::iterator iter;
		std::vector<char*>::iterator iter_str = reconfigStr.begin();
		for(iter = downloaderList.begin(); iter != downloaderList.end(); iter++,iter_str++)
		{
			temp_app =(pixelDownloader*) *iter;
			if (syncLevel == -1 && syncMaster && syncServerObj)
				syncServerObj->removeSyncGroup(temp_app->instID);
			delete temp_app;
			temp_app = NULL;
			temp_str =(char*) *iter_str;
			delete temp_str;
			temp_str = NULL;
		}
		if(downloaderList.size() > 0)
			appShutdown = true;
		downloaderList.clear();
		reconfigStr.clear();
   }
   else if (instID >= 0) {
		int index;
		temp_app = findApp(instID, index);
		if (temp_app)
		{
			delete temp_app;
			temp_app = NULL;
			temp_str = (char*) reconfigStr[index];
			delete temp_str;
			temp_str = NULL;
			downloaderList.erase(downloaderList.begin() + index);
			reconfigStr.erase(reconfigStr.begin() + index);
      	appShutdown = true;
			//shared->displayObj->onAppShutdown(instID);
			if (syncLevel== -1 && syncMaster && syncServerObj)
				syncServerObj->removeSyncGroup(instID);
		}
   }

   if (appShutdown)
      shared->displayObj->setDirty();
   else {
      sage::printLog("sageDisplayManager::shutdownApp : no apps to be shutdown");
      return -1;
   }

   return 0;
}
int sageDisplayManager::changeDepth(sageMessage *msg)
{
   char *depthStr = (char *)msg->getData();
   char token[TOKEN_LEN];
   char *tokenbuf; // strtok_r requires 3rd parameter

   //int tokenNum = getToken(depthStr, token);
   getToken(depthStr, token, &tokenbuf);

   int numOfChange = atoi(token);
   bool zOrderChange = false;

	int index;
	pixelDownloader*  temp_app;
	int instID, zValue;
   for (int i=0; i<numOfChange; i++) {
/*
      if (tokenNum > 0) {
         tokenNum = getToken(depthStr, token);
         instID = atoi(token);
      }
      else {
         sage::printLog("More arguments are needed for this command ");
         return -1;
      }

      if (tokenNum > 0) {
         tokenNum = getToken(depthStr, token);
         zValue = atoi(token);
      }
      else {
         sage::printLog("More arguments are needed for this command ");
         return -1;
      }
      */
	   getToken(NULL, token, &tokenbuf);
	   instID = atoi(token);
	   getToken(NULL, token, &tokenbuf);
	   zValue = atoi(token);

		temp_app = findApp(instID, index);
      if (temp_app) {
         float depth = 1.0f + zValue - 0.01f*index;
         //float depth = 1.0f + zValue;
         temp_app->setDepth(depth);
         zOrderChange = true;
      }
   }

   if (zOrderChange)
      shared->displayObj->setDirty();

   return 0;
}
Beispiel #9
0
void QuickLauncher::addAppBeforeManually(TQString url, TQString sender)
{
    if (sender.isNull())
    {
        addApp(url, Append, true);
    }
    int pos = findApp(sender);
    if (pos < 0) 
    {
        pos = Append;
    }
    DEBUGSTR << "QuickLauncher::addAppBefore(" << url << 
                "," << sender << "):  pos=" << pos << endl << flush;
    addApp(url, pos, true);
}
Beispiel #10
0
void QuickLauncher::addApp(TQString url, int index, bool manuallyAdded)
{
    DEBUGSTR << endl <<"About to add: url='" << url << 
                "' index=" << index << endl << flush;
    QuickButton *newButton;
    if (!m_buttons->isValidInsertIndex(index))
    {
        kdWarning() << "    *******WARNING****** index=" << index << 
            "is out of bounds." << endl << flush;
        index = m_buttons->lastIndex();
    }
    int old = findApp(QuickURL(url).url());
    if (old != NotFound)
    {
        if (index == old)
        {
            return;
        }
        if (index > old)
        {
            index--;
        }
        newButton = (*m_buttons)[old];
        m_buttons->eraseAt(old);
    }
    else
    {
        newButton = createButton(url);
    }
    m_buttons->insertAt(index, newButton);
    DEBUGSTR << "Added: url='"<<url<<"' index="<<index<<endl<<endl<<flush;
    refreshContents();

    if (manuallyAdded)
    {
        newButton->setSticky(true);
        if (int(m_buttons->size()) > m_settings->autoAdjustMaxItems())
        {
            m_settings->setAutoAdjustMaxItems(m_buttons->size());
        }
    }

    updateInsertionPosToStatusQuo();
    saveConfig();
}
//Scans a directory for PSP Applications and adds them on the list
void ApplicationsManager::scanDir(QString dir, QList<PSPApplication> &list)
{
    QFileInfo fi(dir);
    if (!fi.isDir())
    {
        return;
    }
    
    QDir directory(dir);
    
    QFileInfoList dirList = directory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
    for (int i = 0; i < dirList.size(); ++i)
    {
        QDir appDir(dirList.at(i).filePath());
        QFileInfoList appDirList = appDir.entryInfoList(QDir::Files | QDir::NoSymLinks);
        for (int j = 0; j < appDirList.size(); j++)
        {
            if (appDirList.at(j).fileName().toLower() == "eboot.pbp")
            {
            		try
            		{
                		PSPApplication app(appDirList.at(j).filePath());
                		//We only add the app if it's a new one
                		//This is the easiest way to get rid of the
                		//multiple pbp problem
                		if (!findApp(list, app.getPath()))
                		{
                    		list.append(app);
                		}
                }
                catch (QPSPManagerPBPException e)
        				{
            				m_view.showErrorMessage(tr("%1 doesn't seem to be a valid application").arg(appDirList.at(j).filePath()));
        				}
            }
        }
    }
}
int sageDisplayManager::startPerformanceReport(sageMessage *msg)
{
   char *perfStr = (char *)msg->getData();
   int instID, rate;
   sscanf(perfStr, "%d %d", &instID, &rate);

   //std::cout << "start perf report " << rate << std::endl;

	int index;
	pixelDownloader *loader = findApp(instID, index);
   if (loader) {
      //loader->setReportRate(rate);
      //loader->resetTimer();
      //loader->resetBandWidth();
      //loader->resetFrame();
   }
   else {
      sage::printLog("sageDisplayManager::startPerformanceReport : invalid app instance ID");
      return -1;
   }

   return 0;
}
Beispiel #13
0
void QuickLauncher::slotAdjustToCurrentPopularity()
{
    // TODO: Shrink immediately if buttons->size() > maxItems
    kdDebug() << "Starting popularity update" << endl;
    PopularityStatistics* stats = m_popularity;
    int minItems = m_settings->autoAdjustMinItems();
    int maxItems = m_settings->autoAdjustMaxItems();

    static const double hysteresisFactor = 0.90;
    double minAddPopularity = 0;
    for (int n = 0; n < maxItems; ++n)
    {
        // All items with a popularity not less than 0.75 of the average
        // of the first maxItems apps are included in the list
        double belowAvgAllowed = 0.75;
        minAddPopularity += (belowAvgAllowed * stats->popularityByRank(n)) / maxItems;
    }
    double minDelPopularity = minAddPopularity * hysteresisFactor;
    std::map<TQString, QuickButton*> removeableApps;
    std::set<TQString> existingApps;
    int numApps = m_buttons->size();
    for (int n = 0; n < int(m_buttons->size()); ++n)
    {
        QuickButton *button = (*m_buttons)[n];
        if (((stats->popularityByRank(stats->rankByService(button->menuId())) <
             minDelPopularity) || m_settings->autoAdjustEnabled()==false) && 
            (button->sticky() == false)) 
        {
            removeableApps[button->menuId()] = button;
            --numApps;
        }
        existingApps.insert(button->menuId());
    }
    for (int n = 0; 
         (numApps < minItems && stats->popularityByRank(n) > 0) ||
         (numApps < maxItems && stats->popularityByRank(n) > minAddPopularity);
         ++n)
    {
        TQString app = m_popularity->serviceByRank(n);
        if (existingApps.find(app) == existingApps.end())
        {
            addApp(QuickURL(m_popularity->serviceByRank(n)).url(), false);
            kdDebug() << "Adding app " << app << endl;
            ++numApps;
        }
        else if (removeableApps.find(app) != removeableApps.end())
        {
            removeableApps.erase(app);
            ++numApps;
        }
    }
    while (removeableApps.size() > 0)
    {
        removeApp(findApp(removeableApps.begin()->second), false);
        kdDebug() << "Removing app " << removeableApps.begin()->first << endl;
        removeableApps.erase(removeableApps.begin()->first);
    }
    kdDebug() << "done popularity update" << endl;
    m_settings->setAutoAdjustMinItems(minItems);
    m_settings->setAutoAdjustMaxItems(maxItems);

    // TODO: Think of something better than that:
    m_saveTimer->start(10000,true);
}
int sageDisplayManager::parseEvent(sageEvent *event)
{
   if (!event) {
      sage::printLog("sageDisplayManager::parseEvent : event object is Null");
      return -1;
   }

   switch (event->eventType) {
      case EVENT_NEW_CONNECTION : {
         initStreams(event->eventMsg, (streamProtocol *)event->param);
         break;
      }

      case EVENT_NEW_MESSAGE : {
         parseMessage((sageMessage *)event->param);
         break;
      }

      case EVENT_SYNC_MESSAGE : {
         //processSync((char *)event->eventMsg);
    	  processSync( event );
         break;
      }

      case EVENT_REFRESH_SCREEN : {
         if (shared->displayObj->isDirty())
            shared->displayObj->updateScreen(shared, false);

         if (shared->context)
            shared->context->checkEvent();
         break;
      }

      case EVENT_READ_BLOCK : {
         int instID = atoi((char *)event->eventMsg);
			if (0 > instID) break;

			int index;
			pixelDownloader*  temp_app = findApp(instID, index);
			if (temp_app) {
            if (temp_app->getStatus() == PDL_WAIT_DATA)
               temp_app->fetchSageBlocks();
         }
         break;
      }

		case EVENT_APP_CONNECTED : {
         int instID = atoi((char *)event->eventMsg);
			if (0 > instID) break;

			int index;
			pixelDownloader*  temp_app = findApp(instID, index);

			if (temp_app) {
            sendMessage(DISP_APP_CONNECTED, instID);
         }
         break;
		}
   }

   delete event;

   return 0;
}
int sageDisplayManager::initStreams(char *msg, streamProtocol *nwObj)
{
   int senderID, instID, streamType, frameRate;

   sscanf(msg, "%d %d %d %d", &senderID, &streamType, &frameRate, &instID);

   if ( syncLevel == 0 ) {
	   streamType = SAGE_BLOCK_NO_SYNC;
   }

   //std::cout << "stream info " << msg << std::endl;

   /**
    * if pixelDownloader object for this application hasn't created before, then create one
	*/
	int index;
	pixelDownloader*  dwloader = findApp(instID, index);

   if (dwloader) {
		if (dwloader->isInitialized() == true)  {
      	dwloader->addStream(senderID); // EVENT_APP_CONNECTED will be arisen
			return 0;
		}
	} else {
		dwloader = new pixelDownloader;
		dwloader->instID = instID;
		downloaderList.push_back(dwloader);
		reconfigStr.push_back(NULL);
		index = downloaderList.size()-1;
	}

   //creates pixelDownloader if it's not there.
	switch(streamType) {
         case SAGE_BLOCK_NO_SYNC : {
            if (syncMaster) {
			   sage::printLog("\nSDM::initStreams() : Application %d is starting. NO_SYNC", instID);
            }
		   dwloader->init(msg, shared, nwObj, false, syncLevel);
            break;
         }
         case SAGE_BLOCK_HARD_SYNC : {
		   if ( syncMaster ) {
			   sage::printLog("\nSDM::initStreams() : Application %d is starting. SYNC", instID);
		   }
		   dwloader->init(msg, shared, nwObj, true, syncLevel);

		   // syncLevel == -1 // OLD sync
			if (syncLevel == -1 && syncMaster && syncServerObj) {
               syncGroup *sGroup = new syncGroup;
               sGroup->init(0, SAGE_ASAP_SYNC_HARD, instID, DISPLAY_MAX_FRAME_RATE);
               syncServerObj->addSyncGroup(sGroup);
            }
            break;
         }
	}

	if (reconfigStr[index])
		dwloader->enqueConfig(reconfigStr[index]);

	dwloader->addStream(senderID);
   return 0;
}
Beispiel #16
0
void
initJobInfo( JobInfo* jobinfo, int argc, char* const* argv )
/* purpose: initialize the data structure with defaults
 * paramtr: jobinfo (OUT): initialized memory block
 *          argc (IN): adjusted argc string (maybe from main())
 *          argv (IN): adjusted argv string to point to executable
 */
{
#ifdef USE_PARSE
  size_t i;
  char* t;
  int state = 0;
  Node* head = parseArgVector( argc, argv, &state );
#endif

  /* initialize memory */
  memset( jobinfo, 0, sizeof(JobInfo) );

#ifdef USE_PARSE
  /* only continue in ok state AND if there is anything to do */
  if ( state == 32 && head ) {
    size_t size, argc = size = 0;
    Node* temp = head;

    while ( temp ) {
      size += (strlen(temp->data) + 1);
      argc++;
      temp = temp->next;
    }

    /* prepare copy area */
    jobinfo->copy = (char*) malloc( size+argc );

    /* prepare argument vector */
    jobinfo->argc = argc;
    jobinfo->argv = (char* const*) calloc( argc+1, sizeof(char*) );

    /* copy list while updating argument vector and freeing lose arguments */
    t = jobinfo->copy;
    for ( i=0; i < argc && (temp=head); ++i ) {
      /* append string to copy area */
      size_t len = strlen(temp->data)+1;
      memcpy( t, temp->data, len );
      /* I hate nagging compilers which think they know better */
      memcpy( (void*) &jobinfo->argv[i], &t, sizeof(char*) );
      t += len;

      /* clear parse list while we are at it */
      head = temp->next;
      free((void*) temp->data );
      free((void*) temp );
    }
  }
   
  /* free list of (partial) argv */
  if ( head ) deleteNodes(head);

#else
  /* this may require overwriting after CLI parsing */
  jobinfo->argc = argc;
  jobinfo->argv = argv;

#endif 

  /* this is a valid (and initialized) entry */
  if ( jobinfo->argc > 0 ) {
    /* check out path to job */
    char* realpath = findApp( jobinfo->argv[0] );

    if ( realpath ) {
      /* I hate nagging compilers which think they know better */
      memcpy( (void*) &jobinfo->argv[0], &realpath, sizeof(char*) );
      jobinfo->isValid = 1;
    } else {
      jobinfo->status = -127;
      jobinfo->saverr = errno;
      jobinfo->isValid = 2;
    }

    /* initialize some data for myself */
    initStatInfoFromName( &jobinfo->executable, jobinfo->argv[0], O_RDONLY, 0 );
  }
}
Beispiel #17
0
void
initJobInfoFromString( JobInfo* jobinfo, const char* commandline )
/* purpose: initialize the data structure with default
 * paramtr: jobinfo (OUT): initialized memory block
 *          commandline (IN): commandline concatenated string to separate
 */
{
  size_t i;
  char* t;
#ifdef USE_PARSE
  int state = 0;
  Node* head = parseCommandLine( commandline, &state );
#else
  char* s;
#endif

  /* reset everything */
  memset( jobinfo, 0, sizeof(JobInfo) );

#ifdef USE_PARSE
  /* only continue in ok state AND if there is anything to do */
  if ( state == 32 && head ) {
    size_t size, argc = size = 0;
    Node* temp = head;
    while ( temp ) {
      size += (strlen(temp->data) + 1);
      argc++;
      temp = temp->next;
    }

    /* prepare copy area */
    jobinfo->copy = (char*) malloc( size+argc );

    /* prepare argument vector */
    jobinfo->argc = argc;
    jobinfo->argv = (char* const*) calloc( argc+1, sizeof(char*) );

    /* copy list while updating argument vector and freeing lose arguments */
    t = jobinfo->copy;
    for ( i=0; i < argc && (temp=head); ++i ) {
      /* append string to copy area */
      size_t len = strlen(temp->data)+1;
      memcpy( t, temp->data, len );
      /* I hate nagging compilers which think they know better */
      memcpy( (void*) &jobinfo->argv[i], &t, sizeof(char*) );
      t += len;

      /* clear parse list while we are at it */
      head = temp->next;
      free((void*) temp->data );
      free((void*) temp );
    }
  }
   
  /* free list of (partial) argv */
  if ( head ) deleteNodes(head);

#else
  /* activate copy area */
  jobinfo->copy = strdup( commandline ? commandline : "" );

  /* prepare argv buffer for arguments */
  jobinfo->argc = countArguments(commandline);
  jobinfo->argv = (char* const*) calloc( 1+jobinfo->argc, sizeof(char*) );

  /* copy argument positions into pointer vector */
  for ( i=0, s=jobinfo->copy; *s && i < jobinfo->argc; i++ ) {
    while ( *s && isspace(*s) ) *s++ = '\0';
    t = s;
    while ( *s && ! isspace(*s) ) ++s;
    jobinfo->argv[i] = t; 
  }

  /* remove possible trailing whitespaces */
  while ( *s && isspace(*s) ) *s++ = '\0';
  
  /* finalize vector */
  jobinfo->argv[i] = NULL;
#endif

  /* this is a valid (and initialized) entry */
  if ( jobinfo->argc > 0 ) {
    /* check out path to job */
    char* realpath = findApp( jobinfo->argv[0] );

    if ( realpath ) {
      /* I hate nagging compilers which think they know better */
      memcpy( (void*) &jobinfo->argv[0], &realpath, sizeof(char*) );
      jobinfo->isValid = 1;
    } else {
      jobinfo->status = -127;
      jobinfo->saverr = errno;
      jobinfo->isValid = 2;
    }
    /* initialize some data for myself */
    initStatInfoFromName( &jobinfo->executable, jobinfo->argv[0], O_RDONLY, 0 );
  }
}
int sageDisplayManager::processSync(sageEvent *e)
{
	if ( syncLevel == -1 ) {
		int groupID, syncFrame, dataLen, cmd;
		sscanf(e->eventMsg, "%d %d %d %d", &groupID, &syncFrame, &dataLen, &cmd);

		int index;
		pixelDownloader *loader = findApp(groupID, index);
		if (loader) {
			loader->processSync(syncFrame, cmd);
			if (loader->getStatus() == PDL_WAIT_SYNC)
				loader->fetchSageBlocks();
		}
		return 0;
	}

	int *intMsg=(int *)(e->eventMsg); // one for pdl id one for syncFrame
	//int pdlID, activeRcvs, curFrame, updatedFrame, syncFrame;
	bool swapMontageDone = false;

	pixelDownloader *PDL = NULL;
	//std::vector<pixelDownloader*>::iterator iter;
	int index;
	int numIndex = e->buflen / sizeof(int);
	numIndex = numIndex - 1; // The first element is the message length in Byte
	numIndex = numIndex / 2; // this is the number of app which have updated in this round
	for ( int i=0; i<numIndex; i++ ) {
		/**
		* if it's unsigned type, then it should be checked with UINT_MAX or ULONG_MAX or ULLONG_MAX
		*/
		//if ( intMsg[2*i+1] < 0 ) break;

		PDL = findApp(intMsg[2*i+1], index);
		if ( PDL ) {
			swapMontageDone = true;

#ifdef DEBUG_SYNC
			fprintf(stderr, "[%d,%d] SDM::processSync() : It's ready for frame %d\n", shared->nodeID, intMsg[2*i], intMsg[2*i+1]);
#endif

			// trigger to swapMontage
			PDL->processSync(intMsg[2*i+2]);

			// if PDL is waiting sync
			/*
			if (PDL->getStatus() == PDL_WAIT_SYNC) {

				// wake it up
				PDL->fetchSageBlocks(); // should change PDL status
			}
			 */
		}
	}

	switch(syncLevel) {
	case 1:
		// data sync only
		// 1st phase only
		//		shared->displayObj->update(); // ratko version only
		if ( swapMontageDone ) {
			shared->displayObj->updateScreen(shared, false); // barrier flag false
		}
		else if ( shared->displayObj->isDirty() ) {
			shared->displayObj->updateScreen(NULL, false);
		}
		else {
			// do nothing
		}
		break;
	case 2:
		// swap buffer sync. default
		// 2nd phase
		//		shared->displayObj->update();
		if ( swapMontageDone ) {
			shared->displayObj->updateScreen(shared, true); // barrier flag true
		}
		else if ( shared->displayObj->isDirty() ) {
			// no precise sync is needed
			// refresh needed for Ratko

			// comment out below two when using SELECTIVE barrier
			shared->syncClientObj->sendRefreshBarrier(shared->nodeID);
			shared->syncClientObj->recvRefreshBarrier(true); // nonblocking = true

			shared->displayObj->updateScreen(shared, false); // barrier flag must be false here, otherwise it will enter barrier in sageDisplay::updateScreen() again
		}
		else  {
			// no precise sync is needed. just execute barrier here
			// no refreshing needed

			// comment out below two when using SELECTIVE barrier
			shared->syncClientObj->sendRefreshBarrier(shared->nodeID);
			shared->syncClientObj->recvRefreshBarrier(true); // nonblocking = true

			// NO SCREEN REFRESH
			//shared->displayObj->updateScreen(shared, false);
		}
		break;
	case 3:
		// NTP method
		/** delay compensation after 1st phase.
		* This replaces 2nd phase entirely
		* effectively reducing 2n messages
		*/
		//int index = SAGE_SYNC_MSG_LEN / sizeof(int); // array index
		/*
		int index = SAGE_SYNC_MSG_LEN / sizeof(long long); // array index
		shared->deltaT = intMsg[index-1];
		shared->syncMasterT.tv_sec = (time_t)intMsg[index-2];
		shared->syncMasterT.tv_usec = (suseconds_t)intMsg[index-3];
		 */
		break;
	}

	for ( int i=0; i<numIndex; i++ ) {
		PDL = findApp(intMsg[2*i+1], index);
		// if PDL is waiting sync
		if (PDL  &&  PDL->getStatus() == PDL_WAIT_SYNC) {
			// wake it up
			PDL->fetchSageBlocks(); // should change PDL status
		}
	}
	return 0;
}