Example #1
0
/**
 * Called when we get a rfbFramebufferUpdate message.
 */
static void rf_host_fbupdate_hdr(void)
{
  CARD8 hdr_buf[4];

  rect_count = buf_get_CARD16(&cur_slot->readbuf[1]);

  if (rect_count == 0xFFFF) {
    log_write(LL_DETAIL, "Receiving framebuffer update");
  } else {
    log_write(LL_DETAIL, "Receiving framebuffer update, %d rectangle(s)",
              rect_count);
  }

  hdr_buf[0] = 0;
  memcpy(&hdr_buf[1], cur_slot->readbuf, 3);
  fbs_spool_data(hdr_buf, 4);

  if (rect_count) {
    aio_setread(rf_host_fbupdate_recthdr, NULL, 12);
  } else {
    log_write(LL_DEBUG, "Requesting incremental framebuffer update");
    request_update(1);
    aio_setread(rf_host_msg, NULL, 1);
  }
}
Example #2
0
/*
 * This function is called by decoders after each rectangle
 * has been successfully decoded.
 */
void fbupdate_rect_done(void)
{
  if (cur_rect.w != 0 && cur_rect.h != 0) {
    log_write(LL_DEBUG, "Received rectangle ok");

    /* Cached data for this rectangle is not valid any more */
    invalidate_enc_cache(&cur_rect);

    /* Save data in a file if necessary */
    fbs_flush_data();

    /* Queue this rectangle for each client */
    aio_walk_slots(fn_host_add_client_rect, TYPE_CL_SLOT);
  }

  if (--rect_count) {
    aio_setread(rf_host_fbupdate_recthdr, NULL, 12);
  } else {
    /* Done with the whole update */
    aio_walk_slots(fn_client_send_rects, TYPE_CL_SLOT);
    log_write(LL_DEBUG, "Requesting incremental framebuffer update");
    request_update(1);
    aio_setread(rf_host_msg, NULL, 1);
  }
}
//=================================================================================================
void eve::dx11::structured_buffer::push_data(float const * p_data, size_t p_num, size_t p_padding)
{
	eve::core::assertion(p_data);
	eve::core::assertion((sizeof(float) * (p_padding + p_num)) <= buffer_size_);
	eve::mem::memcpy(buffer_data_ + p_padding, p_data, p_num * sizeof(float));
	request_update();
}
Example #4
0
	void Server::remove_from_connections(const SmallAddress& addr) {
		request_update();
		for (Connection* c : conns)
			if (c->address.equals(addr))
			{
				conns.remove(c);
				delete c;
				return;
			}
	}
Example #5
0
void update_time(struct tm *time) {
	// maybe hacky but good enough for my purpose
	if ((time->tm_sec % 30) == 0) request_update(NULL);
	char* time_format;
	if (time->tm_year == 0 || clock_is_24h_style()) {
		time_format = (time->tm_sec % 2) ? "%H:%M" : "%H.%M";
	} else {
		time_format = (time->tm_sec % 2) ? "%I:%M" : "%I.%M";
	}

	strftime(time_str, sizeof(time_str), time_format, time);

	// Kludge to handle lack of non-padded hour format string
	// for twelve hour clock.
	if (!clock_is_24h_style() && (time_str[0] == '0')) {
		memmove(time_str, &time_str[1], sizeof(time_str) - 1);
	}

	text_layer_set_text(text_time_layer, time_str);
}
Example #6
0
void window::resize(float a_width, float a_height) {
  setGeometry(QRectF(x(), y(), a_width, a_height + window_title_height()));

  if (priv->m_window_content) {
    if (priv->m_window_type == kApplicationWindow ||
        priv->m_window_type == kPopupWindow) {
      priv->m_window_content->setPos(0.0, window_title_height());
    }
  }

  std::for_each(std::begin(priv->m_window_resized_callback_list),
                std::end(priv->m_window_resized_callback_list),
                [&](ResizeCallback a_callback) {
    if (a_callback)
      a_callback(this, geometry().width(), geometry().height());
  });

  update();
  request_update();
}
Example #7
0
static void host_really_activate(AIO_SLOT *slot)
{
  AIO_SLOT *saved_slot = cur_slot;
  HOST_SLOT *hs = (HOST_SLOT *)slot;

  log_write(LL_MSG, "Activating new host connection");
  slot->type = TYPE_HOST_ACTIVE_SLOT;
  s_host_slot = slot;

  write_active_file();
  perform_action("host_activate");

  /* Allocate the framebuffer or extend its dimensions if necessary */
  if (!alloc_framebuffer(hs->fb_width, hs->fb_height)) {
    aio_close(1);
    return;
  }

  /* Set default desktop geometry for new client connections */
  g_screen_info.width = hs->fb_width;
  g_screen_info.height = hs->fb_height;

  /* If requested, open file to save this session and write the header */
  fbs_open_file(hs->fb_width, hs->fb_height);

  cur_slot = slot;

  /* Reset zlib streams in the Tight decoder */
  reset_tight_streams();

  /* Request initial screen contents */
  log_write(LL_DETAIL, "Requesting full framebuffer update");
  request_update(0);
  aio_setread(rf_host_msg, NULL, 1);

  /* Notify clients about desktop geometry change */
  aio_walk_slots(fn_host_pass_newfbsize, TYPE_CL_SLOT);

  cur_slot = saved_slot;
}
Example #8
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
	if (is_buzzing()) {
		alarm_silence();
	}
	request_update(NULL);
}
Example #9
0
void window::mouseReleaseEvent(QGraphicsSceneMouseEvent *a_event_ptr) {
  invoke_window_moved_action();
  QGraphicsObject::mouseReleaseEvent(a_event_ptr);
  request_update();
}
Example #10
0
void window::mousePressEvent(QGraphicsSceneMouseEvent *event) {
  if (event->button() == Qt::LeftButton)
    invoke_focus_handlers();
  QGraphicsObject::mousePressEvent(event);
  request_update();
}
Example #11
0
void window::hide() {
  setVisible(false);
  request_update();
}
Example #12
0
void window::show() {
  setVisible(true);
  request_update();
}
Example #13
0
void window::set_window_title(const QString &a_window_title) {
  priv->m_window_title = a_window_title;
  update();
  request_update();
}
Example #14
0
void window::set_window_content(widget *a_widget_ptr) {
  if (priv->m_window_content) {
    return;
  }

  priv->m_window_content = a_widget_ptr;
  priv->m_window_content->setParentItem(this);

  float window_bordr_height = window_title_height();

  QRectF content_geometry(a_widget_ptr->boundingRect());
#ifdef __APPLE__
  content_geometry.setHeight(content_geometry.height() + window_title_height() +
                             30);
  content_geometry.setWidth(content_geometry.width() + 30);
#else
  content_geometry.setHeight(content_geometry.height() + window_title_height());
  content_geometry.setWidth(content_geometry.width() + 2);
#endif

  if (priv->m_window_type == kApplicationWindow) {
#ifdef __APPLE__
    priv->m_window_content->setPos(15.0, window_bordr_height + 10);
    content_geometry.setHeight(content_geometry.height());
#else
    priv->m_window_content->setPos(1.0, window_bordr_height);
    content_geometry.setHeight(content_geometry.height() + 8);
#endif
    setGeometry(content_geometry);
  } else if (priv->m_window_type == kNotificationWindow) {
#ifdef __APPLE__
    priv->m_window_content->setPos(15.0, window_bordr_height + 10);
#else
    priv->m_window_content->setPos(0.0, window_bordr_height);
#endif

    priv->m_window_close_button->hide();
    setGeometry(content_geometry);
  } else if (priv->m_window_type == kPanelWindow) {
    priv->m_window_close_button->hide();
#ifdef __APPLE__
    setGeometry(content_geometry);
    priv->m_window_content->setPos(15.0, window_bordr_height);
    a_widget_ptr->setFlag(QGraphicsItem::ItemIsMovable, false);
#else
    setGeometry(priv->m_window_content->geometry());
    priv->m_window_content->setPos(0, 4);
#endif
    setFlag(QGraphicsItem::ItemIsMovable, false);
    setFlag(QGraphicsItem::ItemIsFocusable, true);
  } else if (priv->m_window_type == kPopupWindow) {
    priv->m_window_close_button->hide();
    setGeometry(content_geometry);
#ifdef __APPLE__
    priv->m_window_content->setPos(15, window_bordr_height + 10);
#else
    priv->m_window_content->setPos(0, window_bordr_height);
#endif
  } else {
    priv->m_window_close_button->hide();
    setGeometry(content_geometry);
    priv->m_window_content->setPos(0,
                                   window_bordr_height + window_title_height());
  }

  if (priv->m_window_type != kFramelessWindow) {
#ifndef __APPLE__
    QGraphicsDropShadowEffect *lEffect = new QGraphicsDropShadowEffect(this);
    lEffect->setColor(QColor("#111111"));
    lEffect->setBlurRadius(26);
    lEffect->setXOffset(0);
    lEffect->setYOffset(0);
    setGraphicsEffect(lEffect);
    setCacheMode(NoCache);
#endif
  }

  if (priv->m_window_type == kFramelessWindow) {
    setFlag(QGraphicsItem::ItemIsMovable, false);
    setFlag(QGraphicsItem::ItemIsFocusable, true);
    enable_window_background(false);
  }

  request_update();
}
Example #15
0
void protocol_download()
{
	UpdateResp update = { 0 };
	uint8 nIndex;
	uint16 nOffset;

	power_device(ED_GPRS, EP_ON);
	post_trace("gprs power on");
	if(!gprs_dial(APN_USER, APN_PASS)) {
		post_trace("gprs dial error");
		power_device(ED_GPRS, EP_OFF);
		
		return;
	}
	if(!gprs_connect(SERVER_ADDR, SERVER_PORT)) {
		post_trace("gprs connect error");
		power_device(ED_GPRS, EP_OFF);
		
		return;
	}
	if(!request_update(&update)) {
		gprs_disconnect();
		power_device(ED_GPRS, EP_OFF);
		
		return;
	}
	
	complete_communication();
	
	for(nIndex = 0; nIndex < ECT_COUNT; ++nIndex) {
		if(0 == update.update[nIndex] || EV_REMOVE == update.update[nIndex]) {
			continue;
		}
		if(ECT_HEALTH == nIndex) {
			uchar szBuf[SERVER_DATA_SIZE] = { 0 };
			char szPath[max_path] = { 0 };
			uint8 nLen;
			
			sprintf(szPath, "%s0", HEALTH_PATH);
			for(nOffset = 0; nOffset < update.update[nIndex]; ++nOffset) {
				nLen = SERVER_DATA_SIZE;
				if(!download_health(nOffset, szBuf, &nLen)) {
					break;
				}
				if(!write_file_ex(szPath, szBuf, nLen, nOffset * SERVER_DATA_SIZE)) {
					break;
				}
			}
			complete_communication();
		} else if(ECT_CONFIG == nIndex) {
			Config config = { 0 };
			
			if(!download_config(0, &config)) {
				continue;
			}
		   	save_server_config(&config);
			complete_communication();
		} else if(ECT_RELATION == nIndex) {
			Relation relation = { 0 };
			char szPath[max_path] = { 0 };
			uint8 nFile = 0;
			
			if(EV_REMOVE == update.update[nIndex]) {
				// remove relation
				continue;
			}
			for(nOffset = 0; nOffset < update.update[nIndex]; ++nOffset) {
				if(!download_relation(nOffset, &relation)) {
					continue;
				}
				sprintf(szPath, "%s%d", RELATION_PATH, nFile++);
				if(!write_file(szPath, &relation, sizeof(Relation))) {
					--nFile;
				}
			}
			complete_communication();
		} else if(ECT_REMIND == nIndex) {
			Remind remind = { 0 };
			char szPath[max_path] = { 0 };
			uint8 nFile = 0;
			
			if(EV_REMOVE == update.update[nIndex]) {
				// remove remind
				continue;
			}
			for(nOffset = 0; nOffset < update.update[nIndex]; ++nOffset) {
				if(!download_remind(nOffset, &remind)) {
					continue;
				}
				sprintf(szPath, "%s%d", RELATION_PATH, nFile++);
				if(!write_file(szPath, &remind, sizeof(Remind))) {
					--nFile;
				}
			}
			complete_communication();
		}
	}
	
	gprs_disconnect();
	power_device(ED_GPRS, EP_OFF);
}
Example #16
0
	Connection* Server::add_to_connections(const SmallAddress& addr) {
		request_update();
		Connection* new_conn = new Connection(sock, addr);
		conns.push_back(new_conn);
		return new_conn;
	}