Beispiel #1
0
void layoutLiskVerifyAddress(const char *address) {
  const char **str =
      split_message((const uint8_t *)address, strlen(address), 10);
  layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Confirm"),
                    _("Confirm address?"), _("Message signed by:"), str[0],
                    str[1], NULL, NULL, NULL);
}
Beispiel #2
0
bool InstantMessaging::send_iax_message (iax_session* session, const std::string& id, const std::string& message)
{

    bool ret;

    /* Check the length of the message */
    if (message.length() < getMessageMaximumSize()) {
        /* No problem here */
        ret = iax_send (session, id, message);
    }

    else {
        /* It exceeds the size limit of a SIP MESSAGE (1300 bytes), o plit it and send multiple messages */
        std::vector<std::string> multiple_messages = split_message (message);
        /* Send multiple messages */
        // int size = multiple_messages.size();
        int i = 0;

        // Maximum is above 1500 character
        // TODO: Send every messages
        ret = iax_send (session, id, multiple_messages[i]);
    }

    return ret;
}
Beispiel #3
0
void layoutCipherKeyValue(bool encrypt, const char *key)
{
	const char **str = split_message((const uint8_t *)key, strlen(key), 16);
	layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
		encrypt ? _("Encrypt value of this key?") : _("Decrypt value of this key?"),
		str[0], str[1], str[2], str[3], NULL, NULL);
}
Beispiel #4
0
void layoutEncryptMessage(const uint8_t *msg, uint32_t len, bool signing)
{
	const char **str = split_message(msg, len, 16);
	layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
		signing ? _("Encrypt+Sign message?") : _("Encrypt message?"),
		str[0], str[1], str[2], str[3], NULL, NULL);
}
Beispiel #5
0
void layoutDecryptMessage(const uint8_t *msg, uint32_t len, const char *address)
{
	const char **str = split_message(msg, len, 16);
	layoutDialogSwipe(&bmp_icon_info, NULL, _("OK"),
		address ? _("Decrypted signed message") : _("Decrypted message"),
		str[0], str[1], str[2], str[3], NULL, NULL);
}
Beispiel #6
0
/**
 * Sends a error message to the ReKick Driver
 *
 * \see \ref debug
 * \see \ref error
 *
 * \param str A NULL terminated string
 */
void warning(char *str) {

	uint8_t len = strlen(str);

	if (str[len-1] != '\n') {
		char newstr[len+2];
		memcpy(newstr, str, len);
		newstr[len] = '\n';
		newstr[len+1] = 0x00;
		split_message(CMD_WARNING, newstr);
	}
	else {
		split_message(CMD_WARNING, str);
	}

	return;
}
Beispiel #7
0
/**
 * Sends a error message to the ReKick Driver
 *
 * \see \ref debug
 * \see \ref warning
 *
 * \param str A NULL terminated string
 */
void error(char *str) {

	uint8_t len = strlen(str);

	if (str[len-1] != '\n') {
		char newstr[len+2];
		memcpy(newstr, str, len);
		newstr[len] = '\n';
		newstr[len+1] = 0x00;
		split_message(CMD_ERROR, newstr);
	}
	else {
		split_message(CMD_ERROR, str);
	}

	return;
}
Beispiel #8
0
void layoutRequireConfirmTx(char *recipient_id, uint64_t amount) {
  char formated_amount[MAX_LISK_VALUE_SIZE];
  const char **str =
      split_message((const uint8_t *)recipient_id, strlen(recipient_id), 16);
  lisk_format_value(amount, formated_amount);
  layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
                    _("Confirm sending"), formated_amount, _("to:"), str[0],
                    str[1], NULL);
}
Beispiel #9
0
void layoutRequireConfirmDelegateRegistration(LiskTransactionAsset *asset) {
  if (asset->has_delegate && asset->delegate.has_username) {
    const char **str = split_message((const uint8_t *)asset->delegate.username,
                                     strlen(asset->delegate.username), 20);
    layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
                      _("Confirm transaction"), _("Do you really want to"),
                      _("register a delegate?"), str[0], str[1], NULL);
  }
}
Beispiel #10
0
void layoutVerifyMessage(const uint8_t *msg, uint32_t len)
{
	const char **str;
	if (!is_valid_ascii(msg, len)) {
		str = split_message_hex(msg, len);
		layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Confirm"),
			_("Verified binary message"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	} else {
		str = split_message(msg, len, 20);
		layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Confirm"),
			_("Verified message"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	}
}
Beispiel #11
0
void layoutSignMessage(const uint8_t *msg, uint32_t len)
{
	const char **str;
	if (!is_valid_ascii(msg, len)) {
		str = split_message_hex(msg, len);
		layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
			_("Sign binary message?"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	} else {
		str = split_message(msg, len, 20);
		layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
			_("Sign message?"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	}
}
Beispiel #12
0
char *get_message(const char *param)
{
	char **split;
	int i;
	
	split_message(&split, (char *)param, '.');
	
	for(i = 0; lang_s[i].group != NULL; i++) {
		if(!strcmp(split[2], lang_s[i].group))
			break;
		++i;
	}
	
	return lang_s[i].mes;
}
Beispiel #13
0
/*
 * Terminal version of a balloon, uses the popup menu code.
 */
    void
ui_post_balloon(char_u *mesg, list_T *list)
{
    ui_remove_balloon();

    if (mesg == NULL && list == NULL)
	return;
    if (list != NULL)
    {
	listitem_T  *li;
	int	    idx;

	balloon_arraysize = list->lv_len;
	balloon_array = (pumitem_T *)alloc_clear(
				   (unsigned)sizeof(pumitem_T) * list->lv_len);
	if (balloon_array == NULL)
	    return;
	for (idx = 0, li = list->lv_first; li != NULL; li = li->li_next, ++idx)
	{
	    char_u *text = get_tv_string_chk(&li->li_tv);

	    balloon_array[idx].pum_text = vim_strsave(
					   text == NULL ? (char_u *)"" : text);
	}
    }
    else
	balloon_arraysize = split_message(mesg, &balloon_array);

    if (balloon_arraysize > 0)
    {
	pum_array = balloon_array;
	pum_size = balloon_arraysize;
	pum_compute_size();
	pum_scrollbar = 0;
	pum_height = balloon_arraysize;

	pum_position_at_mouse(BALLOON_MIN_WIDTH);
	pum_selected = -1;
	pum_first = 0;
	pum_redraw();
    }
}
Beispiel #14
0
static int
internal_query_draw( widget_query_entry *query, int save, const char *message )
{
  widget_query_entry *ptr;
  size_t height = 0;
  int menu_width;
  int menu_left_edge_x;
  int i;

  if( split_message( message, &message_lines, &num_message_lines, 28 ) ) {
    return 1;
  }

  menu_width = widget_calculate_query_width( title, query, message_lines,
					     num_message_lines );

  height = num_message_lines;

  /* How many options do we have? */
  for( ptr = query; ptr->text; ptr++ )
    height ++;

  menu_left_edge_x = DISPLAY_WIDTH_COLS/2-menu_width/2;

  /* Draw the dialog box */
  widget_dialog_with_border( menu_left_edge_x, 2, menu_width, 2 + height );

  widget_printstring( menu_left_edge_x*8+2, 16, WIDGET_COLOUR_TITLE, title );

  for( i=0; i<num_message_lines; i++ ) {
    widget_printstring( menu_left_edge_x*8+8, i*8+24,
                        WIDGET_COLOUR_FOREGROUND, message_lines[i] );
  }

  for( ptr = query; ptr->text; ptr++ ) {
    widget_query_line_draw( menu_left_edge_x, menu_width, ptr, ptr->text );
  }

  widget_display_lines( 2, 2 + height );

  return 0;
}
Beispiel #15
0
void layoutConfirmOpReturn(const uint8_t *data, uint32_t size)
{
	const char **str;
	if (!is_valid_ascii(data, size)) {
		str = split_message_hex(data, size);
	} else {
		str = split_message(data, size, 20);
	}
	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		_("Confirm"),
		NULL,
		_("Confirm OP_RETURN:"),
		str[0],
		str[1],
		str[2],
		str[3],
		NULL
	);
}
Beispiel #16
0
static void render_address_dialog(const CoinInfo *coin, const char *address, const char *line1, const char *line2, const char *extra_line)
{
	if (coin && coin->cashaddr_prefix) {
		/* If this is a cashaddr address, remove the prefix from the
		 * string presented to the user
		 */
		int prefix_len = strlen(coin->cashaddr_prefix);
		if (strncmp(address, coin->cashaddr_prefix, prefix_len) == 0
			&& address[prefix_len] == ':') {
			address += prefix_len + 1;
		}
	}
	int addrlen = strlen(address);
	int numlines = addrlen <= 42 ? 2 : 3;
	int linelen = (addrlen - 1) / numlines + 1;
	if (linelen > 21) {
		linelen = 21;
	}
	const char **str = split_message((const uint8_t *)address, addrlen, linelen);
	layoutLast = layoutDialogSwipe;
	layoutSwipe();
	oledClear();
	oledDrawBitmap(0, 0, &bmp_icon_question);
	oledDrawString(20, 0 * 9, line1, FONT_STANDARD);
	oledDrawString(20, 1 * 9, line2, FONT_STANDARD);
	int left = linelen > 18 ? 0 : 20;
	oledDrawString(left, 2 * 9, str[0], FONT_FIXED);
	oledDrawString(left, 3 * 9, str[1], FONT_FIXED);
	oledDrawString(left, 4 * 9, str[2], FONT_FIXED);
	oledDrawString(left, 5 * 9, str[3], FONT_FIXED);
	if (!str[3][0]) {
		if (extra_line) {
			oledDrawString(0, 5 * 9, extra_line, FONT_STANDARD);
		} else {
			oledHLine(OLED_HEIGHT - 13);
		}
	}
	layoutButtonNo(_("Cancel"));
	layoutButtonYes(_("Confirm"));
	oledRefresh();
}
Beispiel #17
0
int widget_error_draw( void *data )
{
    char **lines;
    size_t count;
    size_t i;

    error_info = (widget_error_t*)data;
    if( split_message( error_info->message, &lines, &count, 28 ) ) return 1;

    widget_dialog_with_border( 1, 2, 30, count+2 );

    switch( error_info->severity ) {
    case UI_ERROR_INFO:
        widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "Info" );
        break;
    case UI_ERROR_WARNING:
        widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "Warning" );
        break;
    case UI_ERROR_ERROR:
        widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "Error" );
        break;
    default:
        widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "(Unknown message)" );
        break;
    }

    for( i=0; i<count; i++ ) {
        widget_printstring( 17, i*8+24, WIDGET_COLOUR_FOREGROUND, lines[i] );
        free( lines[i] );
    }

    free( lines );

    widget_display_lines( 2, count + 3 );

    return 0;
}
      void NuboEarDetectorImpl::onEar (gchar *message)
      {

	/*the String received will be like this ( the ; is the seperation among ears): 
	  x:int,y:int,width:int,height:int;x:int,y:int,width:int,height:int;*/
	std::string del1 = ";";
	std::string del2 = ",";
	std::string del3 = ":";
	std::vector<std::string> *ears = new std::vector<std::string>;
	std::vector<std::string> *fields = new std::vector<std::string>;
	std::vector<std::string> *all = new std::vector<std::string>;
	std::vector<EarInfo> *f_info = new std::vector<EarInfo>;
  
	bool register_completed=true;
	int i=0;
  
	try {
    
	  split_message(message,del1,ears);
	  for( i=0; (int)(ears->size())>i; i++) 
	    split_message(ears->at(i),del2,fields);
    
	  for( i=0; (int)(fields->size())>i; i++)
	    split_message(fields->at(i),del3,all);
    
	  EarInfo *mi;
    
	  for(int i=0; (int)(all->size())>i; i=i+2)
	    {
	
	      if (register_completed)
		{
		  mi= new EarInfo("ear",-1,-1,-1,-1);
		  register_completed=false;
		}
	      if (0==all->at(i).compare("x")) 	
		{
		  if ((i+1)< (int)(all->size()))	      
		    mi->setX(std::stoi(all->at(i+1)));
		}
	      else if (0==all->at(i).compare("y")) 
		{
		  if ((i+1)< (int)(all->size()))
		    mi->setY(std::stoi(all->at(i+1)));
		}
	
	      else if (0==all->at(i).compare("width"))     
		{
		  if ((i+1)< (int)(all->size()))
		    mi->setWidth(std::stoi(all->at(i+1)));
		}
	      else if (0==all->at(i).compare("height"))     
		{
		  if ((i+1)< (int)(all->size()))
		    {
		      mi->setHeight(std::stoi(all->at(i+1)));
		      register_completed=true;
		      f_info->push_back(*mi);
		    }
		}
	    }

	  std::vector<std::shared_ptr<EarInfo>> test;
    
	  for (i=0;i<(int)(f_info->size());i++)
	    {
	      std::shared_ptr <EarInfo> f1 (&(f_info->at(i)));
	      test.push_back(f1);
	    }
   
	  OnEar event (shared_from_this(), OnEar::getName(), test);
	  signalOnEar (event);
	} catch (std::bad_weak_ptr &e) {
	}
      }
Beispiel #19
0
int
n2a_event_service_check (int event_type __attribute__ ((__unused__)), void *data)
{
  //logger(LG_DEBUG, "Event: event_host_check");
  nebstruct_service_check_data *c = (nebstruct_service_check_data *) data;

  if (c->type == NEBTYPE_SERVICECHECK_PROCESSED)
    {
      //logger(LG_DEBUG, "SERVICECHECK_PROCESSED: %s->%s", c->host_name, c->service_description);
      char *buffer = NULL, *key = NULL;

      size_t l = xstrlen(g_options.connector) +
      xstrlen(g_options.eventsource_name) + xstrlen(c->host_name) + xstrlen(c->service_description) + 20;
      // "..check.ressource.." + \0 = 20 chars

      json_t *jdata = NULL;
      size_t message_size = 0;

      int nbmsg = nebstruct_service_check_data_to_json(c, &jdata, &message_size); 

      // DO NOT FREE !!!
      xalloca(key, xmin(g_options.max_size, (int)l) * sizeof(char));

      snprintf(key, xmin(g_options.max_size, (int)l),
                 "%s.%s.check.resource.%s.%s", g_options.connector,
                 g_options.eventsource_name, c->host_name,
                 c->service_description);

      if (nbmsg == 1) {
          char *json = json_dumps(jdata, 0);
          buffer = xmalloc (message_size + 1);

          snprintf (buffer, message_size + 1, "%s", json);

          if (c_size == -10000 || c_size / 2 == 0) 
              amqp_publish(key, buffer);
          else
              n2a_record_cache (key, buffer);

          xfree(buffer);
          xfree (json);
      } else {
          int left = g_options.max_size - (int)message_size;
          size_t l_out = xstrlen(c->long_output);
          size_t out = xstrlen(c->output);
          size_t perf = xstrlen(c->perf_data);
          int msgs = ((int)l_out/left + 1) + ((int)out/left + 1) + ((int)perf/left + 1);
          n2a_logger(LG_INFO, "Data too long... sending %d messages for host: %s, service: %s", msgs, c->host_name, c->service_description);
          int i, temp;
          split_message(c->long_output, "long_output");
          split_message(c->output, "output");
          split_message(c->perf_data, "perf_data");
      }

      if (jdata != NULL)
          json_decref (jdata);

    }

  return 0;
}
void NuboNoseDetectorImpl::onNose (gchar *message)
{

  /*the String received will be like this ( the ; is the seperation among noses): 
    x:int,y:int,width:int,height:int;x:int,y:int,width:int,height:int;*/
  std::string del1 = ";";
  std::string del2 = ",";
  std::string del3 = ":";
  std::vector<std::string> *noses = new std::vector<std::string>;
  std::vector<std::string> *fields = new std::vector<std::string>;
  std::vector<std::string> *all = new std::vector<std::string>;
  std::vector<std::shared_ptr<NoseInfo>> test;
  int x,y,height,width;
  std::string t; 
  
  bool register_completed=true;
  int i=0;

  try {
    
    split_message(message,del1,noses);
    for( i=0; (int)(noses->size())>i; i++) 
      split_message(noses->at(i),del2,fields);
    
    for( i=0; (int)(fields->size())>i; i++)
      split_message(fields->at(i),del3,all);
    
    NoseInfo *fi;
    
    for(int i=0; (int)(all->size())>i; i=i+2)
      {
	
	if (register_completed)
	  {
	    t="nose";
	    x=0;y=0;width=0;height=0;
	    register_completed=false;
	  }
	if (0==all->at(i).compare("x")) 	
	  {
	    if ((i+1)< (int)(all->size()))	      
	      x=std::stoi(all->at(i+1));
	  }
	else if (0==all->at(i).compare("y")) 
	  {
	    if ((i+1)< (int)(all->size()))
	      y=std::stoi(all->at(i+1));
	  }
	
	else if (0==all->at(i).compare("width"))     
	  {
	    if ((i+1)< (int)(all->size()))
	      width=std::stoi(all->at(i+1));
	  }
	else if (0==all->at(i).compare("height"))     
	  {
	    if ((i+1)< (int)(all->size()))
	      {
		height=std::stoi(all->at(i+1));
		std::shared_ptr <NoseInfo> cand ( new NoseInfo(t,x,y,width,height));
		test.push_back(cand);
		register_completed=true;
	      }
	  }
      }
   
    if (test.size()>0)
      {
	OnNose event (shared_from_this(), OnNose::getName(), test);
	signalOnNose (event);
      }
  } catch (std::bad_weak_ptr &e) {
  }
}
Beispiel #21
0
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count, bool address_is_account)
{
	if (layoutLast != layoutAddress) {
		layoutSwipe();
	} else {
		oledClear();
	}
	layoutLast = layoutAddress;

	uint32_t addrlen = strlen(address);
	if (qrcode) {
		static unsigned char bitdata[QR_MAX_BITDATA];
		char address_upcase[addrlen + 1];
		if (ignorecase) {
			for (uint32_t i = 0; i < addrlen + 1; i++) {
				address_upcase[i] = address[i] >= 'a' && address[i] <= 'z' ?
					address[i] + 'A' - 'a' : address[i];
			}
		}
		int side = qr_encode(addrlen <= (ignorecase ? 60 : 40) ? QR_LEVEL_M : QR_LEVEL_L, 0,
							 ignorecase ? address_upcase : address, 0, bitdata);

		oledInvert(0, 0, 63, 63);
		if (side > 0 && side <= 29) {
			int offset = 32 - side;
			for (int i = 0; i < side; i++) {
				for (int j = 0; j< side; j++) {
					int a = j * side + i;
					if (bitdata[a / 8] & (1 << (7 - a % 8))) {
						oledBox(offset + i * 2, offset + j * 2,
								offset + 1 + i * 2, offset + 1 + j * 2, false);
					}
				}
			}
		} else if (side > 0 && side <= 60) {
			int offset = 32 - (side / 2); 
			for (int i = 0; i < side; i++) {
				for (int j = 0; j< side; j++) {
					int a = j * side + i;
					if (bitdata[a / 8] & (1 << (7 - a % 8))) {
						oledClearPixel(offset + i, offset + j);
					}
				}
			}
		}
	} else {
		if (desc) {
			oledDrawString(0, 0 * 9, desc, FONT_STANDARD);
		}
		if (addrlen > 10) { // don't split short addresses
			uint32_t rowlen = (addrlen - 1) / (addrlen <= 42 ? 2 : addrlen <= 63 ? 3 : 4) + 1;
			const char **str = split_message((const uint8_t *)address, addrlen, rowlen);
			for (int i = 0; i < 4; i++) {
				oledDrawString(0, (i + 1) * 9 + 4, str[i], FONT_FIXED);
			}
		} else {
			oledDrawString(0, (0 + 1) * 9 + 4, address, FONT_FIXED);
		}
		oledDrawString(0, 42, address_n_str(address_n, address_n_count, address_is_account), FONT_STANDARD);
	}

	if (!qrcode) {
		layoutButtonNo(_("QR Code"));
	}

	layoutButtonYes(_("Continue"));
	oledRefresh();
}