コード例 #1
0
ファイル: Object.cpp プロジェクト: ACefalu/tzod
void GC_Object::PulseNotify(NotifyType type, void *param)
{
	++_notifyProtectCount;
	for( Notify *n = _firstNotify; n; n = n->next )
	{
		if( type == n->type && !n->IsRemoved() )
		{
			((n->subscriber)->*n->handler)(this, param);
		}
	}
	--_notifyProtectCount;
	if( 0 == _notifyProtectCount )
	{
		for( Notify *prev = NULL, *n = _firstNotify; n; )
		{
			if( n->IsRemoved() )
			{
				Notify *&pp = prev ? prev->next : _firstNotify;
				pp = n->next;
				delete n;
				n = pp;
			}
			else
			{
				prev = n;
				n = n->next;
			}
		}
	}
}
コード例 #2
0
ファイル: Event.cpp プロジェクト: davidswelt/XCSoar
void
EventLoop::Dispatch(SDL_Event &event)
{
  if (event.type == EVENT_USER && event.user.data1 != NULL) {
    Window *window = (Window *)event.user.data1;
    window->OnUser(event.user.code);
  } else if (event.type == EVENT_CALLBACK) {
    Callback callback = (Callback)event.user.data1;
    callback(event.user.data2);
  } else if (event.type == EVENT_NOTIFY && event.user.data1 != NULL) {
    Notify *notify = (Notify *)event.user.data1;
    notify->RunNotification();
  } else
    top_window.on_event(event);
}
コード例 #3
0
ファイル: Event.cpp プロジェクト: damianob/xcsoar
void
EventLoop::Dispatch(const Event &event)
{
  if (event.type == Event::USER) {
    Window *window = (Window *)event.ptr;
    window->OnUser(event.param);
  } else if (event.type == Event::TIMER) {
    AndroidTimer *timer = (AndroidTimer *)event.ptr;
    timer->run();
  } else if (event.type == Event::CALLBACK) {
    event.callback(event.ptr);
  } else if (event.type == Event::NOTIFY) {
    Notify *notify = (Notify *)event.ptr;
    notify->RunNotification();
  } else if (event.type != Event::NOP)
    top_window.OnEvent(event);
}
コード例 #4
0
ファイル: ProfileField.cpp プロジェクト: Artanomell/schat
bool ProfileField::isMatch(const Notify &notify)
{
  int type = notify.type();
  if (type != Notify::FeedReply && type != Notify::FeedData)
    return false;

  const FeedNotify &n = static_cast<const FeedNotify &>(notify);
  return n.match(ChatClient::id(), FEED_NAME_PROFILE);
}
コード例 #5
0
ファイル: NetworkManager.cpp プロジェクト: johnbolia/schat
void NetworkManager::notify(const Notify &notify)
{
  if (notify.type() == Notify::ServerRenamed) {
    Network item = this->item(ChatClient::serverId());
    if (!item)
      return;

    item->setName(ChatClient::serverName());
    item->write();
  }
}
コード例 #6
0
ファイル: pomelocpp.cpp プロジェクト: qiyuelei/pomelocpp
void Client::NotifyResponse(const Notify & notify,int rc)
{
	int key = notify.GetId();
	if(notifyHandlers.find(key) != notifyHandlers.end())
	{
		auto callback = notifyHandlers[key];
		if(callback){
			callback(notify,rc);
		}
		notifyHandlers.erase(key);
	}
}
コード例 #7
0
ファイル: ProfileField.cpp プロジェクト: Artanomell/schat
void ProfileField::notify(const Notify &notify)
{
  if (!isMatch(notify))
    return;

  if (notify.type() == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (!n.json().contains(m_field))
      return;
  }

  reload();
}
コード例 #8
0
ファイル: ChatView.cpp プロジェクト: youngdev/schat
void ChatView::notify(const Notify &notify)
{
  const int type = notify.type();

  if (type == Notify::ClearChat) {
    if (m_id == notify.data().toByteArray())
      clearPage();
  }
  else if (type == Notify::FeedData || type == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.channel() == id() || n.channel() == ChatClient::id() || (n.channel() == ChatClient::serverId() && n.feed() == FEED_NAME_ACL)) {
      const QVariantMap json = WebBridge::feed(n);
      if (json.isEmpty())
        return;

      if (!m_loaded)
        m_pendingFeeds.enqueue(json);
      else
        emit feed(json);
    }
  }
}
コード例 #9
0
ファイル: HistoryChatView.cpp プロジェクト: youngdev/schat
void HistoryChatView::notify(const Notify &notify)
{
  if (notify.type() == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.feed() == FEED_NAME_MESSAGES && n.path() == MESSAGES_FEED_LAST_KEY) {
      if (n.status() == Notice::NotModified) {
        const QList<QByteArray> messages = HistoryDB::last(n.channel());
        HistoryImpl::get(n.channel(), messages);
        emulateLast(n.channel(), messages);
      }
      else if (n.status() == Notice::OK && !n.json().contains(MESSAGES_FEED_BEFORE_KEY) && !n.json().contains(MESSAGES_FEED_EMULATED_KEY))
        HistoryDB::add(n.channel(), n.json().value(MESSAGES_FEED_MESSAGES_KEY).toStringList());
    }
  }
}
コード例 #10
0
ファイル: ConsoleCmd.cpp プロジェクト: johnbolia/schat
void ConsoleCmd::notify(const Notify &notify)
{
  if (notify.type() == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.channel() == ChatClient::serverId() && n.name() == CONSOLE_FEED_COOKIE_REQ && !m_cookie.isEmpty()) {
      if (n.status() == Notice::OK) {
        const QByteArray id = SimpleID::decode(n.json().value(LS("user")).toString());
        if (m_cookie == id)
          AlertMessage::show(LS("<b>Cookie:</b> ") + n.json().value(CONSOLE_FEED_COOKIE_KEY).toString(), ALERT_MESSAGE_INFO);
      }

      m_cookie.clear();
    }

  }
}
コード例 #11
0
ファイル: ChannelsView.cpp プロジェクト: Artanomell/schat
void ChannelsView::notify(const Notify &notify)
{
  int type = notify.type();
  if (type == Notify::FeedData || type == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.channel() != ChatClient::serverId())
      return;

    QVariantMap json = WebBridge::feed(n);
    if (json.isEmpty())
      return;

    emit feed(json);
  }
  else if (type == Notify::ServerRenamed) {
    emit serverRenamed(ChatClient::serverName());
  }
}
コード例 #12
0
ファイル: DaleDFB.cpp プロジェクト: touchao123/ilixi
void
DaleDFB::notificationListener(void* ctx, void* arg)
{
    Compositor::NotificationAckData data = *((Compositor::NotificationAckData*) arg);
    if (data.client != getpid())
        return;

    for (Notifications::iterator it = __nots.begin(); it != __nots.end(); ++it)
    {
        Notify* n = ((Notify*) *it);
        if (strcmp(n->uuid(), data.uuid) == 0)
        {
            if (data.method == Compositor::Click)
                n->sigClick();
            else if (data.method == Compositor::Close)
                n->sigClose();
            else if (data.method == Compositor::Error)
                n->sigError();
            else if (data.method == Compositor::Show)
                n->sigShow();
            return;
        }
    }
}
コード例 #13
0
ファイル: Object.cpp プロジェクト: ACefalu/tzod
void GC_Object::Serialize(SaveFile &f)
{
	assert(0 == _notifyProtectCount);

	f.Serialize(_flags);


	//
	// name
	//

	if( CheckFlags(GC_FLAG_OBJECT_NAMED) )
	{
		if( f.loading() )
		{
			string_t name;
			f.Serialize(name);

			assert( 0 == g_level->_objectToStringMaps[FastLog2(GC_FLAG_OBJECT_NAMED)].count(this) );
			assert( 0 == g_level->_nameToObjectMap.count(name) );
			g_level->_objectToStringMaps[FastLog2(GC_FLAG_OBJECT_NAMED)][this] = name;
			g_level->_nameToObjectMap[name] = this;
		}
		else
		{
			string_t name = GetName();
			f.Serialize(name);
		}
	}


	//
	// events
	//

	if( f.loading() )
	{
		DWORD tmp = _flags & GC_FLAG_OBJECT_EVENTS_TS_FIXED;
		SetFlags(GC_FLAG_OBJECT_EVENTS_TS_FIXED, false);
		SetEvents(tmp);
	}


	//
	// notifications
	//

	size_t count = 0;
	if( const Notify *n = _firstNotify )
		do { count += !n->IsRemoved(); } while( n = n->next );
	f.Serialize(count);
	if( f.loading() )
	{
		assert(NULL == _firstNotify);
		for( size_t i = 0; i < count; i++ )
		{
			_firstNotify = new Notify(_firstNotify);
			_firstNotify->Serialize(f);
		}
	}
	else
	{
		for( Notify *n = _firstNotify; n; n = n->next )
		{
			if( !n->IsRemoved() )
				n->Serialize(f);
		}
	}
}
コード例 #14
0
void Remote::event()
{
	switch(bt.event)
	{
		case BT_EVENT_DISCONNECT:
			notify.unWatch(&remote_notify); // stop all active notifications
			//debug(STR("REMOTE::EVENT: Disconnected\r\n"));
			connected = 0;
			break;

		case BT_EVENT_CONNECT:
			connected = 1;
			//debug(STR("REMOTE::EVENT: Connected\r\n"));
			request(REMOTE_MODEL);
			break;

		case BT_EVENT_DATA:
			switch(bt.dataId)
			{
				case REMOTE_STATUS:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(timer_status)) memcpy(&status, bt.data, bt.dataSize);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_STATUS, (void *)&timer.status, sizeof(timer.status), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_STATUS, &remote_notify);
					break;
				case REMOTE_PROGRAM:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(program)) memcpy(&current, bt.data, bt.dataSize);
					if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(program))
					{
						memcpy((void*)&timer.current, bt.data, bt.dataSize);
						menu.refresh();
					}
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_PROGRAM, (void *)&timer.current, sizeof(timer.current), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_PROGRAM, &remote_notify);
					break;
				case REMOTE_BATTERY:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SEND) memcpy(&battery, bt.data, bt.dataSize);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_BATTERY, (void *)&battery_percent, sizeof(battery_percent), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_BATTERY, &remote_notify);
					break;
				case REMOTE_START:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(timer.running ? REMOTE_START : REMOTE_STOP, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SEND) running = 1;
					if(bt.dataType == REMOTE_TYPE_SET) runHandler(FR_KEY, 1);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_START, (void *)&timer.running, sizeof(timer.running), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_START, &remote_notify);
					break;
				case REMOTE_STOP:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(timer.running ? REMOTE_START : REMOTE_STOP, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SEND) running = 0;
					if(bt.dataType == REMOTE_TYPE_SET) timerStop(FR_KEY, 1);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_START, (void *)&timer.running, sizeof(timer.running), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_START, &remote_notify);
					break;
				case REMOTE_BULB_START:
					if(bt.dataType == REMOTE_TYPE_SET) timer.bulbStart();
					break;
				case REMOTE_BULB_END:
					if(bt.dataType == REMOTE_TYPE_SET) timer.bulbEnd();
					break;
				case REMOTE_CAPTURE:
					if(bt.dataType == REMOTE_TYPE_SET) timer.capture();
					break;
				case REMOTE_MODEL:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(REMOTE_MODEL, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SEND) memcpy(&model, bt.data, bt.dataSize);
					break;
				case REMOTE_FIRMWARE:
				case REMOTE_BT_FW_VERSION:
				case REMOTE_PROTOCOL_VERSION:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					break;
				case REMOTE_CAMERA_FPS:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_CAMERA_FPS, (void *)&conf.cameraFPS, sizeof(conf.cameraFPS), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_CAMERA_FPS, &remote_notify);
					break;
				case REMOTE_CAMERA_MAKE:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_CAMERA_MAKE, (void *)&conf.cameraMake, sizeof(conf.cameraMake), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_CAMERA_MAKE, &remote_notify);
					break;
				case REMOTE_DEBUG:
					if(bt.dataType == REMOTE_TYPE_SEND)
					{
						bt.data[bt.dataSize] = 0;
						debug_remote(bt.data);
					}
					break;
				case REMOTE_ISO:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t))
					{
						uint8_t tmp;
						memcpy((void*)&tmp, bt.data, bt.dataSize);
						camera.setISO(tmp);
					}
					break;
				case REMOTE_APERTURE:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t))
					{
						uint8_t tmp;
						memcpy((void*)&tmp, bt.data, bt.dataSize);
						camera.setAperture(tmp);
					}
					break;
				case REMOTE_SHUTTER:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t))
					{
						uint8_t tmp;
						memcpy((void*)&tmp, bt.data, bt.dataSize);
						camera.setShutter(tmp);
					}
					break;
				case REMOTE_THUMBNAIL:
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					break;
				case REMOTE_VIDEO:
					if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t))
					{
						uint8_t tmp;
						memcpy((void*)&tmp, bt.data, bt.dataSize);
						if(tmp) camera.videoStart(); else camera.videoStop();
					}
					if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(uint8_t))
					{
						uint8_t tmp;
						memcpy((void*)&tmp, bt.data, bt.dataSize);
						if(tmp) recording = true; else recording = false;
					}
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_VIDEO, (void *)&camera.recording, sizeof(camera.recording), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_VIDEO, &remote_notify);
					break;
				case REMOTE_LIVEVIEW:
					if(bt.dataType == REMOTE_TYPE_SET && bt.dataSize == sizeof(uint8_t))
					{
						uint8_t tmp;
						memcpy((void*)&tmp, bt.data, bt.dataSize);
						if(tmp) camera.liveView(tmp);
					}
					if(bt.dataType == REMOTE_TYPE_SEND && bt.dataSize == sizeof(uint8_t))
					{
						uint8_t tmp;
						memcpy((void*)&tmp, bt.data, bt.dataSize);
						if(tmp) modeLiveView = true; else modeLiveView = false;
					}
					if(bt.dataType == REMOTE_TYPE_REQUEST) send(bt.dataId, REMOTE_TYPE_SEND);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_WATCH) notify.watch(REMOTE_LIVEVIEW, (void *)&camera.modeLiveView, sizeof(camera.modeLiveView), &remote_notify);
					if(bt.dataType == REMOTE_TYPE_NOTIFY_UNWATCH) notify.unWatch(REMOTE_LIVEVIEW, &remote_notify);
					break;
				default:
					return;
			}
			bt.event = BT_EVENT_NULL;
			break;
	}
	requestActive = 0;
}
コード例 #15
0
ファイル: StatusBar.cpp プロジェクト: johnbolia/schat
void StatusBar::notify(const Notify &notify)
{
  if (notify.type() == Notify::ServerRenamed)
    setServerName();
}