Exemplo n.º 1
0
int delete_soundemitor(void)
{
	int i,ans;
	ans = alert("Sure you want to delete the soundemitor?",NULL,NULL,"Yes","Cancel",'\r',0);

	if(ans==2)return D_O_K;

	for(i=current_soundemitor;i<map->num_of_soundemitors-1;i++)
	 {
		 map->soundemitor[i].x = map->soundemitor[i+1].x;
		 map->soundemitor[i].y = map->soundemitor[i+1].y;
		 
		 map->soundemitor[i].sound_type = map->soundemitor[i+1].sound_type;
		 map->soundemitor[i].emitor_type = map->soundemitor[i+1].emitor_type;
		 map->soundemitor[i].loop = map->soundemitor[i+1].loop;
		 strcpy(map->soundemitor[i].sound_name, map->soundemitor[i+1].sound_name);
		 		 	 
		 
 	 }
	 map->num_of_soundemitors--;

	return D_O_K;
}
Exemplo n.º 2
0
bool OwlNestSettings::perform(const InvocationInfo& info){
  switch(info.commandID){
  case ApplicationCommands::updateFirmware:
    updateFirmware();
    break;
  case ApplicationCommands::updateBootloader:
    updateBootloader();
    break;
  case ApplicationCommands::checkForFirmwareUpdates:
    downloadFromServer(info.commandID);
    break;
  case ApplicationCommands::checkForBootloaderUpdates:
    downloadFromServer(info.commandID);
    break;
  case ApplicationCommands::owlNestVersionInfo:
    AlertWindow alert("About", ApplicationConfiguration::getApplicationDescription(), juce::AlertWindow::InfoIcon);
    alert.addButton("Close", 1, juce::KeyPress(), juce::KeyPress());
    alert.runModalLoop();
    break;
          
  }
  return true;
}
Exemplo n.º 3
0
//make a new soundemitor
void make_new_soundemitor(int x, int y)
{
	if(map->num_of_soundemitors>= MAX_SOUNDEMITOR_NUM - 1 ) //Check so we have space for the object
	{
		alert("No more soundemitors can be made!",NULL,NULL,"OK",NULL,0,0);
		return;
			
	}
	
	map->soundemitor[map->num_of_soundemitors].x = x;
	map->soundemitor[map->num_of_soundemitors].y = y;

	strcpy( map->soundemitor[map->num_of_soundemitors].sound_name, "none");
	map->soundemitor[map->num_of_soundemitors].sound_type = 0;
	map->soundemitor[map->num_of_soundemitors].emitor_type =0;
	map->soundemitor[map->num_of_soundemitors].loop = 0;
	map->soundemitor[map->num_of_soundemitors].active = 1;
	map->soundemitor[map->num_of_soundemitors].voice_num = -1;
	

	map->num_of_soundemitors++;

}
Exemplo n.º 4
0
int Reset_get_reply_to_reset(char *response, int *device)
{
   char buf[128];
   int next_state;
   int status;
   
   status = read_comport(buf);                  // read comport
   
   if (status == DATA)                           // if new data detected in com port buffer
   {
      strcat(response, buf);                    // append contents of buf to response
      next_state = RESET_GET_REPLY_TO_RESET;    // come back for more data
   }
   else if (status == PROMPT) // if '>' detected
   {
      stop_serial_timer();
      strcat(response, buf);
      *device = process_response("atz", response);
      
      if (*device == INTERFACE_ELM323)
         next_state = RESET_START_ECU_TIMER;
      else if (*device == INTERFACE_ELM327)
         next_state = RESET_SEND_AT_AT1_REQUEST;
      else
         next_state = RESET_CLOSE_DIALOG;
   }
   else if (serial_time_out) // if the timer timed out
   {
      stop_serial_timer(); // stop the timer
      alert("Interface was not found", NULL, NULL, "OK", NULL, 0, 0);
      next_state = RESET_CLOSE_DIALOG; // close dialog
   }  
   else  // serial buffer was empty, but we still got time
      next_state = RESET_GET_REPLY_TO_RESET;
   
   return next_state;
}
Exemplo n.º 5
0
int Reset_get_at_at1_response(char *response)
{
   char buf[128];
   int next_state;
   int status;
   
   status = read_comport(buf);                  // read comport
   
   if (status == DATA)                          // if new data detected in com port buffer
   {
      strcat(response, buf);                    // append contents of buf to response
      next_state = RESET_GET_AT_AT1_RESPONSE;   // come back for more data
   }
   else if (status == PROMPT) // if '>' detected
   {
      stop_serial_timer();
      strcat(response, buf);
      status = process_response("at@1", response);
      
      if (status == STN_MFR_STRING)
         next_state = RESET_START_ECU_TIMER;
      else if (status == ELM_MFR_STRING)
         next_state = RESET_SEND_AT_AT2_REQUEST;
      else
         next_state = RESET_HANDLE_CLONE;
   }
   else if (serial_time_out)
   {
      stop_serial_timer();
      alert("Connection with interface lost", NULL, NULL, "OK", NULL, 0, 0);
      next_state = RESET_CLOSE_DIALOG; // close dialog
   }
   else  // serial buffer was empty, but we still got time
      next_state = RESET_GET_AT_AT1_RESPONSE;
   
   return next_state;
}
Exemplo n.º 6
0
void UF_uArm::init()
{
    // read offset data
    offsetL = EEPROM.read(1);
    offsetR = EEPROM.read(2);
    // initialization the pin
    pinMode(LIMIT_SW, INPUT);  digitalWrite(LIMIT_SW, HIGH);
    pinMode(BTN_D4,   INPUT);  digitalWrite(BTN_D4,   HIGH);
    pinMode(BTN_D7,   INPUT);  digitalWrite(BTN_D7,   HIGH);
    pinMode(BUZZER,   OUTPUT); digitalWrite(BUZZER,   LOW);
    pinMode(PUMP_EN,  OUTPUT); digitalWrite(PUMP_EN,  LOW);
    pinMode(VALVE_EN, OUTPUT); digitalWrite(VALVE_EN, LOW);
	if (EEPROM.read(0) == CALIBRATION_FLAG) // read of offset flag
    {
		// attaches the servo on pin to the servo object
		servoL.attach(SERVO_L, D150A_SERVO_MIN_PUL, D150A_SERVO_MAX_PUL);
		servoR.attach(SERVO_R, D150A_SERVO_MIN_PUL, D150A_SERVO_MAX_PUL);
		servoRot.attach(SERVO_ROT, D150A_SERVO_MIN_PUL, D150A_SERVO_MAX_PUL);
		servoHand.attach(SERVO_HAND, D009A_SERVO_MIN_PUL, D009A_SERVO_MAX_PUL);
		servoHandRot.attach(SERVO_HAND_ROT, D009A_SERVO_MIN_PUL, D009A_SERVO_MAX_PUL);
		servoHand.write(HAND_ANGLE_OPEN, 0, true);
		servoHand.detach();

		servoL.write(map(readAngle(SERVO_L), SERVO_MIN, SERVO_MAX, 0, 180));
		servoR.write(map(readAngle(SERVO_R), SERVO_MIN, SERVO_MAX, 0, 180));
		servoRot.write(map(readAngle(SERVO_ROT), SERVO_MIN, SERVO_MAX, 0, 180));
		// initialization postion
		setServoSpeed(SERVO_R,   20);  // 0=full speed, 1-255 slower to faster
		setServoSpeed(SERVO_L,   20);  // 0=full speed, 1-255 slower to faster
		setServoSpeed(SERVO_ROT, 20);  // 0=full speed, 1-255 slower to faster
		setPosition(stretch, height, rotation, handRot);
    }
    else
    {	// buzzer alert if calibration needed
		alert(3, 200, 200);
    }
}
Exemplo n.º 7
0
static int
save_proc(void)
{
	char filename[1024];
	char buffer[256], *p;
	BITMAP *bmp = NULL;
	int quality = 0, flags = 0;

	if (file_select_ex("Save as JPG", last_path, "jpg", 1024, (SCREEN_W * 2) / 3, (SCREEN_H * 2) / 3)) {
		strcpy(filename, last_path);
		for (p = last_path + strlen(last_path); (p >= last_path) && (*p != '/') && (*p != '\\'); p--)
			;
		*(p + 1) = '\0';
		set_dialog_color(settings_dialog, gui_fg_color, gui_bg_color);
		centre_dialog(settings_dialog);
		if (popup_dialog(settings_dialog, -1) < 0)
			return 0;
		quality = settings_dialog[QUALITY_SLIDER].d2 + 1;
		if (settings_dialog[SS_444_RADIO].flags & D_SELECTED)
			flags = JPG_SAMPLING_444;
		if (settings_dialog[SS_422_RADIO].flags & D_SELECTED)
			flags = JPG_SAMPLING_422;
		if (settings_dialog[SS_411_RADIO].flags & D_SELECTED)
			flags = JPG_SAMPLING_411;
		if (settings_dialog[GREYSCALE_CHECK].flags & D_SELECTED)
			flags |= JPG_GREYSCALE;
		if (settings_dialog[OPTIMIZE_CHECK].flags & D_SELECTED)
			flags |= JPG_OPTIMIZE;
		bmp = settings_dialog[PREVIEW].dp;

		if (save_jpg_ex(filename, bmp, NULL, quality, flags, progress_cb)) {
			sprintf(buffer, "Error saving JPG image (error code %d)", jpgalleg_error);
			alert("", buffer, "", "Ok", NULL, 0, 0);
		}
	}
	return 0;
}
Exemplo n.º 8
0
/*************************************************
Description:    收到一个完整的帧,开始根据类型处理
Calls:          TCPCodec::onMessage
Input:          conn: TCP连接
                frameHeader: 帧头
                message: 帧消息字
                timestamp: 接收时间戳
Output:         无
Return:         无
*************************************************/
void Dispatcher::onStringMessage(const TcpConnectionPtr& conn,
                                shared_ptr<FrameHeader>& frameHeader,
                                shared_ptr<unsigned char>& message,
                                Timestamp timestamp)
{
    switch (frameHeader->type)
    {
        case ALERT:
            alert(conn, frameHeader, message);
            break;
        case TIMING:
            timing(conn, frameHeader, message);
            break;
        case CONFIGURE:
            configuration(conn, frameHeader, message);
            break;
        case CONFIRM:
            confirm(frameHeader->source, message);
            break;
        case LIGHT_MSG:
            lightMessage(conn, frameHeader, message);
            break;
        case ENVIRONMENT_MSG:
            environmentMessage(conn, frameHeader, message);
            break;
        case HUMAN_MSG:
            humanMessage(conn, frameHeader, message);
            break;
        case POWER_MSG:
            powerMessage(conn, frameHeader, message);
            break;
        default:
            LOG_WARN << "UnKnow Message Type";
            break;
    }
}
Exemplo n.º 9
0
/* These three functions demonstrate how to query dialog elements.
 */
int info1(void)
{
   char buf1[256];
   char buf2[256] = "";
   int i, s = 0, n;

   listbox_getter(-1, &n);
   /* query the list proc */
   for (i = 0; i < n; i++) {
      if (sel[i]) {
         uszprintf(buf1, sizeof buf1, "%i ", i);
         ustrzcat(buf2, sizeof buf2, buf1);
         s = 1;
      }
   }
   if (s)
      ustrzcat(buf2, sizeof buf2, "are in the multiple selection!");
   else
      ustrzcat(buf2, sizeof buf2, "There is no multiple selection!");
   uszprintf(buf1, sizeof buf1, "Item number %i is selected!",
      the_dialog[LIST_OBJECT].d1);
   alert("Info about the list:", buf1, buf2, "Ok", NULL, 0, 0);
   return D_O_K;
}
Exemplo n.º 10
0
/*
功能:
	OpenCV 彩色分量提取
*/
void CDIP1View::OnCvSplit() 
{
	// TODO: Add your command handler code here
	if(alert(3))
 		return;
	//**************************OpenCV图像处理主要步骤*****************************
	
	//1、把当前bmp图像转化为IplImage图像。1:表示当前bmp图像是灰度图;3:表示当前bmp图像是灰度图
	IplImage *temp = m_dib.cvBmpToIplImage(3);
	
	//2、创建临时图像

	//3、开始图像处理
	m_dib.cvMySplit(temp);
	
	//4、将处理后的图像(一般指第2步创建的图像)数据赋到bmp图像数据
	m_dib.cvDataToBmp(temp);

	//5、释放前两步创建的IplImage图像
	cvReleaseImage(&temp);//释放temp
	
	 //刷新屏幕
 	Invalidate(1);
}
Exemplo n.º 11
0
void eeReadAll()
{
  if(!EeFsOpen() ||
     EeFsck() < 0 ||
     !eeLoadGeneral()
  )
  {
    alert(PSTR("Bad EEprom Data"), true);
    message(PSTR("EEPROM Formatting"));
    EeFsFormat();
    //alert(PSTR("format ok"));
    generalDefault();
    //alert(PSTR("default ok"));

    theFile.writeRlc(FILE_GENERAL, FILE_TYP_GENERAL,(uint8_t*)&g_eeGeneral,sizeof(EEGeneral), true);

    modelDefault(0);
    //alert(PSTR("modef ok"));
    theFile.writeRlc(FILE_MODEL(0), FILE_TYP_MODEL, (uint8_t*)&g_model, sizeof(g_model), true);
    //alert(PSTR("modwrite ok"));
  }

  eeLoadModel(g_eeGeneral.currModel);
}
Exemplo n.º 12
0
bool VersionManager::load()
{
    FILE *fp = fopen("address.ini", "r");
    if(fp)
    {
        fscanf(fp, "%d\n", &mVersionsCount);
        
        for(uint8_t x = 0; x < mVersionsCount; x++)
        {
            Version *version = new Version();
            
            fscanf(fp, "\n%[^\n]", version->versionText);
            fscanf(fp, "%x", &version->versionAddress);
            fscanf(fp, "%d", &version->configId);
            fscanf(fp, "%d", &version->useRSA);
            
            if(version->useRSA)
                fscanf(fp, "%x", &version->rsaAddress);
                
            fscanf(fp, "%x", &version->ipAddress);
            fscanf(fp, "%x", &version->portAddress);
            fscanf(fp, "%d", &version->quantity);
            fscanf(fp, "%d", &version->distance);
            
            mVersions.push_back(version);
        }
        
        fclose(fp);
        return true;
    }
    else
    {
        alert("Error", "Could not open address.ini.");
        return false;
    }
}
Exemplo n.º 13
0
void testObj::test<8>(void)
{
  // making timestamp for all calls prevents timing issues.
  const Timestamp now=Timestamp(123456);
  Persistency::MetaAlertPtrNN maPtrNode( new Persistency::MetaAlert( Persistency::MetaAlert::Name("meta alert node"),
                                                                     0.1, 0.2,
                                                                     makeNewReferenceURL().shared_ptr(),
                                                                     now,
                                                                     1410u ) );
  Persistency::IO::Postgres::MetaAlert malertNode(maPtrNode, t_, dbh_);

  Persistency::Alert::Analyzers sa( AnalyzerPtrNN( new Analyzer(42u, "analyzer name", NULL, NULL, NULL) ) );
  Persistency::AlertPtrNN alertPtr(new Persistency::Alert("abc",
                                                          sa,
                                                          NULL,
                                                          now,
                                                          Severity(SeverityLevel::INFO),
                                                          Certainty(0.42),
                                                          "some description",
                                                          Persistency::Alert::Hosts(),
                                                          Persistency::Alert::Hosts()) );
  Persistency::IO::Postgres::Alert alert(alertPtr, t_, dbh_);
  malertNode.save();
  alert.save();
  malertNode.associateWithAlert( alertPtr );

  const DataBaseID malertNodeID=dbh_->getIDCache()->get( maPtrNode );
  const DataBaseID alertID     =dbh_->getIDCache()->get( alertPtr );
  stringstream ss;
  ss << "SELECT * FROM alert_to_meta_alert_map WHERE id_alert = " << alertID << ";";
  const result r = t_.getAPI<TransactionAPI>().exec(ss);
  ensure_equals("invalid size",r.size(), 1u);
  ensure_equals("invalid Alert ID", ReaderHelper<DataBaseID>::readAsNotNull(r[0]["id_meta_alert"]), malertNodeID);
  ensure_equals("invalid MetaAlert ID", ReaderHelper<DataBaseID>::readAsNotNull(r[0]["id_alert"]), alertID);
  t_.commit();
}
Exemplo n.º 14
0
void loopOne(
        NVideoInput::CVideoCapture& videoCapture,
        size_t bufferId,
        std::vector<std::shared_ptr<NAlgorithms::IAlertAlgorithm>>& algorithms)
{
    CAlertNotification alert(bufferId);
    std::mutex mutex;

    while (true)
    {
        double timeBeging = (double) cv::getTickCount();
        if (videoCapture.processNextFrame(bufferId) &&
                CConfig::getInstance().mRunStatus.mIsRunMotionAlgo)
        {
#ifdef __BUILD_MOTION_ALGO__
            if (CConfig::getInstance().mIsAlgoRunAsync)
            {
                std::string str;
                std::thread thread(
                            CMainFunctions::doAlgoAsync,
                            std::ref(alert),
                            bufferId,
                            std::ref(algorithms),
                            std::ref(mutex),
                            str);
                thread.detach();
            }
            else
            {
                CMainFunctions::doAlgo(alert, bufferId, algorithms);
            }
#endif
        }
        CMainFunctions::sleepTo(timeBeging, bufferId);
    }
}
Exemplo n.º 15
0
BOOL CALLBACK makeSpotifySession(PINIT_ONCE initOnce, PVOID param, PVOID *context) {
	SpotifySessionData *ssd = static_cast<SpotifySessionData *>(param);
	SpotifySession *ss = ssd->ss;
	sp_session *sess = ss->getAnyway();
	pfc::string8 msg = "Enter your username and password to connect to Spotify";

	while (true) {
		{
			LockedCS lock(ss->getSpotifyCS());
			if (SP_ERROR_NO_CREDENTIALS == sp_session_relogin(sess)) {
				try {
					std::auto_ptr<CredPromptResult> cpr = credPrompt(msg);
					sp_session_login(sess, cpr->un.data(), cpr->pw.data(), cpr->save);
				} catch (std::exception &e) {
					alert(e.what());
					return FALSE;
				}
			}
		}
		msg = ss->waitForLogin(ssd->p_abort);
		if (msg.is_empty())
			return TRUE;
	}
}
Exemplo n.º 16
0
void
user_repair (piece_info_t *obj)
{
	if (obj->type == ARMY || obj->type == FIGHTER) alert ();
	else obj->func = REPAIR;
}
Exemplo n.º 17
0
//huangxu@060405:批量删除文章方便
int search(char *id, char *pat, char *pat2, char *pat3, int dt)
{
        FILE *fp;
        char flgadmin=0;//huangxu@060406:管理模式,允许批量删除文章
        int j;//长度
        char board[256], dir[256], buf2[150];
        int total, now=time(0), i, sum=0, n, t;
        struct fileheader x;
        printf("<script language=\"javascript\" src=\"/js/ajax.js\"></script>");
        printf("\
<script language=\"javascript\">\
var BBSURL = '/cgi-bin/bbs/';\
\
function sumFiles()\
{\
	var intCnt = parseInt(document.getElementById('spnCnt').innerHTML);\
	if (isNaN(intCnt))\
	{\
		intCnt = 0;\
	}\
	var i, intFiles, oWin, oDoc;\
	var strLink, strUser;\
	var o;\
	oWin = open('');\
	if (!oWin)\
	{\
		alert('由于弹出窗口被拦截,此功能无法实现.');\
		return false;\
	}\
	oDoc = oWin.document;\
	oDoc.write('<h3 align=\"center\">' + document.getElementById('pTitle').innerHTML + '</h3>');\
	for(i = intFiles = 0; i < intCnt; i++)\
	{\
		o = document.getElementById('div_' + i);\
		if (!o)\
		{\
			continue;\
		}\
		oDoc.write('<table border=\"1\" align=\"center\" width=\"610\">');\
		try\
		{\
			strLink = document.getElementById('aSrc_' + i).getAttribute('href');\
			if (strLink.substring(0,4).toLowerCase() != 'http')\
			{\
				strLink = BBSURL + strLink;\
			}\
		}\
		catch(e)\
		{\
			strLink = '';\
		}\
		oDoc.write('<tr><td>#<span color=\"red\">' + (++intFiles) + '</span> 原文:<a href=\"' + strLink + '\">' + strLink + '</a></td></tr>');\
		oDoc.write('<tr><td>' + o.innerHTML + '</td></tr>');\
		oDoc.write('</table>');\
	}\
	oDoc.write('<p align=\"center\">共找到文章' + intCnt + '篇,本报表包含了其中的' + intFiles + '篇。</p>');\
	oDoc.close();\
}\
var arrCont=new Array();\
function insertAfter(newNode,refNode)\
{\
	var n=false;\
	n=refNode.nextSibling;\
	if(n)\
	{\
		refNode.parentNode.insertBefore(newNode,n);\
	}\
	else\
	{\
		refNode.parentNode.appendChild(newNode);\
	}\
	return newNode;\
}\
Exemplo n.º 18
0
void
user_transport (piece_info_t *obj)
{
	if (obj->type != ARMY) alert();
	else obj->func = WFTRANSPORT;
}
Exemplo n.º 19
0
void
user_armyattack (piece_info_t *obj)
{
	if (obj->type != ARMY) alert ();
	else obj->func = ARMYATTACK;
}
Exemplo n.º 20
0
static int
handlePreferencesCommands (int command, void *data) {
  switch (command & BRL_MSK_CMD) {
    {
      static const char modeString_preferences[] = "prf";
      static Preferences savedPreferences;

    case BRL_CMD_PREFMENU: {
      int ok = 0;

      if (isSpecialScreen(SCR_MENU)) {
        if (prefs.saveOnExit) {
          if (savePreferences()) {
            alert(ALERT_COMMAND_DONE);
          }
        }

        deactivateSpecialScreen(SCR_MENU);
        ok = 1;
      } else if (activateSpecialScreen(SCR_MENU)) {
        updateSessionAttributes();
        savedPreferences = prefs;
        ok = 1;
      }

      if (ok) {
        infoMode = 0;
      } else {
        alert(ALERT_COMMAND_REJECTED);
      }

      break;
    }

    case BRL_CMD_PREFSAVE:
      if (isSpecialScreen(SCR_MENU)) {
        if (savePreferences()) alert(ALERT_COMMAND_DONE);
        deactivateSpecialScreen(SCR_MENU);
      } else if (savePreferences()) {
        alert(ALERT_COMMAND_DONE);
      } else {
        alert(ALERT_COMMAND_REJECTED);
      }
      break;

    case BRL_CMD_PREFLOAD:
      if (isSpecialScreen(SCR_MENU)) {
        setPreferences(&savedPreferences);
        message(modeString_preferences, gettext("changes discarded"), 0);
      } else if (loadPreferences()) {
        alert(ALERT_COMMAND_DONE);
      } else {
        alert(ALERT_COMMAND_REJECTED);
      }
      break;
    }

    default: {
      int arg = command & BRL_MSK_ARG;

      switch (command & BRL_MSK_BLK) {
        {
          MenuItem *item;

        case BRL_CMD_BLK(SET_TEXT_TABLE):
          item = getPreferencesMenuItem_textTable();
          goto doSetMenuItem;

        case BRL_CMD_BLK(SET_ATTRIBUTES_TABLE):
          item = getPreferencesMenuItem_attributesTable();
          goto doSetMenuItem;

        case BRL_CMD_BLK(SET_CONTRACTION_TABLE):
          item = getPreferencesMenuItem_contractionTable();
          goto doSetMenuItem;

        case BRL_CMD_BLK(SET_KEYBOARD_TABLE):
          item = getPreferencesMenuItem_keyboardTable();
          goto doSetMenuItem;

        case BRL_CMD_BLK(SET_LANGUAGE_PROFILE):
          item = getPreferencesMenuItem_languageProfile();
          goto doSetMenuItem;

        doSetMenuItem:
          if (item) {
            unsigned int count = brl.textColumns;

            if (count <= arg) count = arg + 1;
            changeMenuItem(item);

            if (changeMenuSettingScaled(getMenuItemMenu(item), arg, count)) {
              break;
            }
          }

          alert(ALERT_COMMAND_REJECTED);
          break;
        }

        default:
          return 0;
      }

      break;
    }
  }

  return 1;
}
Exemplo n.º 21
0
Arquivo: request.c Projeto: dmt4/ne
char *request_files(const char * const filename, bool use_prefix) {

	char * const cur_dir_name = ne_getcwd(CUR_DIR_MAX_SIZE);
	if (!cur_dir_name) return NULL;

	char * const dir_name = str_dup(filename);
	if (dir_name) {
		int result = 0;
		char * const p = (char *)file_part(dir_name);
		if (p != dir_name) {
			*p = 0;
			result = chdir(tilde_expand(dir_name));
		}
		free(dir_name);
		if (result == -1) return NULL;
	}

	req_list rl;
	bool next_dir;
	char *result = NULL;
	do {
		next_dir = false;
		if (req_list_init(&rl, filenamecmp, true, false, '/') != OK) break;

		DIR * const d = opendir(CURDIR);
		if (d) {

			stop = false;
			for(struct dirent * de; !stop && (de = readdir(d)); ) {
				const bool is_dir = is_directory(de->d_name);
				if (use_prefix && !is_prefix(file_part(filename), de->d_name)) continue;
				if (!req_list_add(&rl, de->d_name, is_dir)) break;
			}

			req_list_finalize(&rl);

			if (rl.cur_entries) {
				/* qsort(rl.entries, rl.cur_entries, sizeof(char *), filenamecmpp); */

				const int t = request_strings(&rl, 0);
				if (t != ERROR) {
					char * const p = rl.entries[t >= 0 ? t : -t - 2];
					if (p[strlen(p) - 1] == '/' && t >= 0) {
						p[strlen(p) - 1] = 0;
						if (chdir(p)) alert();
						else use_prefix = false;
						next_dir = true;
					}
					else {
						result = ne_getcwd(CUR_DIR_MAX_SIZE + strlen(p) + 2);
						if (strcmp(result, "/")) strcat(result, "/");
						strcat(result, p);
						if (t < 0) {
							memmove(result + 1, result, strlen(result) + 1);
							result[0] = 0;
						}
					}
				}
			}

			closedir(d);
		}
		else alert();
		req_list_free(&rl);
	} while(next_dir);

	chdir(cur_dir_name);
	free(cur_dir_name);

	return result;
}
Exemplo n.º 22
0
void s_alert(void)
{
    alert(0);
}
NS_IMETHODIMP
nsAbLDAPAutoCompFormatter::FormatException(int32_t aState, 
                                           nsresult aErrorCode, 
                                           nsIAutoCompleteItem **aItem) 
{
    int32_t errorKey;
    nsresult rv;

    // create an nsIAutoCompleteItem to hold the returned value
    //
    nsCOMPtr<nsIAutoCompleteItem> item = do_CreateInstance(
        NS_AUTOCOMPLETEITEM_CONTRACTID, &rv);

    if (NS_FAILED(rv)) {
        NS_ERROR("nsAbLDAPAutoCompFormatter::FormatException(): couldn't"
                 " create " NS_AUTOCOMPLETEITEM_CONTRACTID "\n");
        return NS_ERROR_NOT_AVAILABLE;
    }

    // get the string bundle service
    //
    nsString errMsg, ldapErrMsg, alertMsg, ldapHint;
    nsString errCodeNum;

    nsCOMPtr<nsIStringBundleService> stringBundleSvc =
        mozilla::services::GetStringBundleService();
    if (stringBundleSvc) {
        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
                 " error getting string bundle service");
        return NS_ERROR_UNEXPECTED;
    }

    // get the string bundles relevant here: the main LDAP bundle,
    // and the ldap AutoCompletion-specific bundle
    //
    nsCOMPtr<nsIStringBundle> ldapBundle, ldapACBundle;

    rv = stringBundleSvc->CreateBundle(
        LDAP_ERROR_BUNDLE,
        getter_AddRefs(ldapBundle));
    if (NS_FAILED(rv)) {
        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
                 " error creating string bundle "
                 LDAP_ERROR_BUNDLE);
        return rv;
    } 

    rv = stringBundleSvc->CreateBundle(
        LDAP_AUTOCOMPLETE_ERROR_BUNDLE,
        getter_AddRefs(ldapACBundle));
    if (NS_FAILED(rv)) {
        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
                 " error creating string bundle "
                 LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
        return rv;
    }

    // get the general error that goes in the dropdown and the window
    // title
    //
    rv = ldapACBundle->GetStringFromID(aState, getter_Copies(errMsg));
    if (NS_FAILED(rv)) {
        NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
                 " error getting general error from bundle "
                 LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
        return rv;
    }

    // for LDAP errors
    //
    if (NS_ERROR_GET_MODULE(aErrorCode) == NS_ERROR_MODULE_LDAP) {

        errorKey = NS_ERROR_GET_CODE(aErrorCode);

        // put the number itself in string form
        //
        errCodeNum.AppendInt(errorKey);

        // get the LDAP error message itself
        //
        rv = ldapBundle->GetStringFromID(NS_ERROR_GET_CODE(aErrorCode), 
                                                getter_Copies(ldapErrMsg));
        if (NS_FAILED(rv)) {
            NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException"
                     "(): error getting string 2 from bundle "
                     LDAP_ERROR_BUNDLE);
            return rv;
        }
  
    } else {

        // put the entire nsresult in string form
        //
        errCodeNum.AppendLiteral("0x");
        errCodeNum.AppendInt(aErrorCode, 16);    

        // figure out the key to index into the string bundle
        //
        const int32_t HOST_NOT_FOUND_ERROR=5000;
        const int32_t GENERIC_ERROR=9999;
        errorKey = ( (aErrorCode == NS_ERROR_UNKNOWN_HOST) ? 
                     HOST_NOT_FOUND_ERROR : GENERIC_ERROR );

        // get the specific error message itself
        rv = ldapACBundle->GetStringFromID(errorKey,
                                           getter_Copies(ldapErrMsg));
        if (NS_FAILED(rv)) {
            NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException"
                     "(): error getting specific non LDAP error-string "
                     "from bundle "
                     LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
            return rv;
        }
    }

    // and try to find a hint about what the user should do next
    //
    const int32_t HINT_BASE=10000;
    const int32_t GENERIC_HINT_CODE = 9999;
    rv = ldapACBundle->GetStringFromID(HINT_BASE + errorKey, 
                                       getter_Copies(ldapHint));
    if (NS_FAILED(rv)) {
        rv = ldapACBundle->GetStringFromID(HINT_BASE + GENERIC_HINT_CODE,
                                           getter_Copies(ldapHint));
        if (NS_FAILED(rv)) {
            NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException()"
                     "(): error getting hint string from bundle "
                     LDAP_AUTOCOMPLETE_ERROR_BUNDLE);
            return rv;
        }
    }
        
    const PRUnichar *stringParams[3] = { errCodeNum.get(),
                                         ldapErrMsg.get(), ldapHint.get() };

    rv = ldapACBundle->FormatStringFromName(
        NS_LITERAL_STRING("errorAlertFormat").get(), stringParams, 3,
        getter_Copies(alertMsg));
    if (NS_FAILED(rv)) {
        NS_WARNING("Failed to format warning string\n");
    }

    // put the error message, between angle brackets, into the XPIDL |value|
    // attribute.  Note that the hardcoded string is only used since 
    // stringbundles have already failed us.
    //
    if (errMsg.Length()) {
        nsString tErrMsg(NS_LITERAL_STRING("<"));
        tErrMsg.Append(errMsg);
        tErrMsg.AppendLiteral(">");
        rv = item->SetValue(tErrMsg);
    } else {
        rv = item->SetValue(
            NS_LITERAL_STRING("<Unknown LDAP autocompletion error>"));
    }

    if (NS_FAILED(rv)) {
        NS_ERROR("nsAbLDAPAutoCompFormatter::FormatException(): "
                 "item->SetValue failed");
        return rv;
    }
    
    // pass the alert message in as the param; if that fails, proceed anyway
    //
    nsCOMPtr<nsISupportsString> alert(do_CreateInstance(
                                           NS_SUPPORTS_STRING_CONTRACTID,
                                           &rv));
    if (NS_FAILED(rv)) {
        NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): "
                   "could not create nsISupportsString");
    } else {
        rv = alert->SetData(alertMsg);
        if (NS_FAILED(rv)) {
            NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): "
                     "alert.Set() failed");
        } else {
            rv = item->SetParam(alert);
            if (NS_FAILED(rv)) {
                NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): "
                           "item->SetParam failed");
            }
        }
    }

    // this is a remote addressbook, set the class name so the autocomplete 
    // item can be styled to show this
    //
    rv = item->SetClassName("remote-err");
    if (NS_FAILED(rv)) {
        NS_WARNING("nsAbLDAPAutoCompleteFormatter::FormatException():"
                   " item->SetClassName() failed");
    }

    // all done; return the item
    //
    NS_IF_ADDREF(*aItem = item);
    return NS_OK;
}
Exemplo n.º 24
0
BOOL FAR PASCAL _EXPORT openTab(HWND hwnd, LPTabData lpTabData)
{
#if defined(_WIN32)
    HMODULE hInstance=InstanceFromWindow(hwnd);
    LPWORD p, lpCreateParams;
#else
    HINSTANCE hInstance=InstanceFromWindow(hwnd);
    LPBYTE p, lpCreateParams;
#endif
    LPBYTE lpszClass, lpszText=NULL;
    HWND hwndPrevChild=GetDlgItem(hwnd, lpTabData->nFrame);
    HFONT hFont;
    int nIndex=TabCtrl_GetCurSel(lpTabData->hwndTab);
    LPDLGTEMPLATE lpDlgTemplate;
    LPDLGITEMTEMPLATE lpDlgItemTemplate;
    LPFONTINFO lpFontInfo;
    HWND hwndChild;
    int nNumControls;
    RECT rc;

    if (nIndex<0)
	return(FALSE);

    lpTabData->nIndex=nIndex;
    lpDlgTemplate=lpTabData->lpTabList[nIndex].lpDlgTemplate;
    hFont=GetWindowFont(hwnd);

    //  Ignore everything in Dialog Template except for the number
    //  of controls.
    nNumControls=lpDlgTemplate->cdit;

#if defined(_WIN32)
    p=(LPWORD)(&lpDlgTemplate->cy+1); 	//  Start of Menu name
#if defined(_TABDEBUG)
    checkResource(hwnd, p, "Start of menu name");
#endif

    if (*p==0xffff)			//  Skip the menu name string
	p+=2;
    else
	while(*p++);

#if defined(_TABDEBUG)
    checkResource(hwnd, p, "Start of class name");
#endif

    if (*p==0xffff)			//  Skip the Class name string
	p+=2;
    else
	while(*p++);

#if defined(_TABDEBUG)
    checkResource(hwnd, p, "Start of caption");
#endif
#else
    p=(LPBYTE)(&lpDlgTemplate->cy+1); 	//  Start of Menu name
    while (*p++);           		//  Skip the menu name string
    while (*p++);           		//  Skip the Class name string
#endif
    while (*p++);           		//  Skip the Caption string
    lpFontInfo=(LPFONTINFO)p; 		//  Start of FONTINFO (if exists)

    //  Find address of first DLGITEMTEMPLATE structure
    if (lpDlgTemplate->style&DS_SETFONT) {
#if defined(_WIN32)
	p=(LPWORD)(&lpFontInfo->PointSize+1);
#if defined(_TABDEBUG)
	checkResource(hwnd, p, "Start of font name");
#endif
#else
	p=(LPBYTE)(&lpFontInfo->PointSize+1);
#endif
	while (*p++);  			//  Skip the Type face name string
	lpDlgItemTemplate=(LPDLGITEMTEMPLATE)p;
    } else
	lpDlgItemTemplate=(LPDLGITEMTEMPLATE)lpFontInfo;

    //  Create all of the child controls
    while (nNumControls--) {
#if defined(_WIN32)
	LPWORD lpwzClass=(LPWORD)(&lpDlgItemTemplate->id+1);
	BYTE szClassBuffer[64];
	LPWORD lpwzText;
	BYTE szTextBuffer[128];
	int nCount;

	lpDlgItemTemplate=(LPDLGITEMTEMPLATE)normalise(lpDlgItemTemplate, lpDlgTemplate, 1);
	lpwzClass=(LPWORD)(&lpDlgItemTemplate->id+1);

	if (*lpwzClass==0xffff) {
	    nCount=2;
	    lpwzText=lpwzClass+2;
	    lpszClass=(LPBYTE)szPredefinedClassNames[*(lpwzClass+1)-PREDEFINEDCNTRLBIT];
	} else {
	    lpszClass=szClassBuffer;
	    nCount=strcpy16to8(szClassBuffer, lpwzClass)+1;
	    lpwzText=lpwzClass+nCount;
	}

#if defined(_TABDEBUG)
	checkResource(hwnd, (LPINT)lpDlgItemTemplate, "Start of child control %d of %d, class \"%s\"",
		      lpDlgTemplate->cdit-nNumControls, lpDlgTemplate->cdit, lpszClass);
#endif

	if (*lpwzText==0xffff) {
	    nCount+=2;
	    lpszText=(LPBYTE)MAKELONG(*(lpszText+1), 0);
	} else {
	    lpszText=szTextBuffer;
	    nCount+=strcpy16to8(szTextBuffer, lpwzText)+1;
	}

	lpCreateParams=normalise(lpwzClass+nCount-1, lpDlgTemplate, 2);
#else
	lpszClass=(LPBYTE)(&lpDlgItemTemplate->style+1);

	if (*lpszClass&PREDEFINEDCNTRLBIT) {
	    lpszText=lpszClass+1;
	    lpszClass=(LPBYTE)szPredefinedClassNames[(WORD)(*lpszClass)-PREDEFINEDCNTRLBIT];
	} else
	    for (lpszText=lpszClass; *lpszText++;);

	//  Find address of number-of-bytes-in-additional-data
	for (lpCreateParams=lpszText; *lpCreateParams++;);
#endif

	//  Do not create any windows with an ID of uIDChangeableArea
	//  This control was used for reference when the template was
	//  created and should not be created.
	if (lpDlgItemTemplate->id!=lpTabData->nFrame) {
	    SetRect(&rc, lpDlgItemTemplate->x,
			 lpDlgItemTemplate->y,
			 lpDlgItemTemplate->x+lpDlgItemTemplate->cx,
			 lpDlgItemTemplate->y+lpDlgItemTemplate->cy);

	    MapDialogRect(hwnd, &rc);

	    hwndChild=CreateWindowEx(WS_EX_NOPARENTNOTIFY,
				     (LPCSTR)lpszClass, (LPCSTR)lpszText,
				     lpDlgItemTemplate->style,
				     rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
				     hwnd, (HMENU)lpDlgItemTemplate->id, hInstance,
				     lpCreateParams);

	    if (!hwndChild) {
		//  The child couldn't be created
		alert(hwnd, "Failed to create control %d (class %s)",
		      lpDlgTemplate->cdit-nNumControls+1, lpszClass);

		return(FALSE);
	    }

	    //  Tell the new control to use the same font as dialog box
	    SetWindowFont(hwndChild, hFont, FALSE);

	    // Fix the Z-Order of the controls
	    SetWindowPos(hwndChild, hwndPrevChild, 0, 0, 0, 0,
			 SWP_NOMOVE|SWP_NOSIZE);

	    hwndPrevChild=hwndChild;
	}

	// Point to the next DlgItemTemplate
	lpDlgItemTemplate=(LPDLGITEMTEMPLATE)(lpCreateParams+1+ *lpCreateParams);
    }

    FORWARD_WM_INITDIALOG(hwnd, 0, 0, lpTabData->lpTabList[nIndex].fpDlgProc);
    return(TRUE);
}
Exemplo n.º 25
0
//
// Do all pre copy checks and start the copy thread
//
bool handle_copy (void)
{
GError		*error = NULL;
std::string	InputPathLabelString,
		OutputPathLabelString;

	CopyThreadAbort = false;

	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pbar), 0);

	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(InputFileRadioButton))){
		data.SourceMediaType	= isFile;
		data.SourceDir		= gtk_entry_get_text (GTK_ENTRY (InputFileEntry));

		if (data.SourceDir.size() == 0){
			alert ("Error: incorrect input filename");
			return FALSE;
		}

	}else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(InputDriveRadioButton))){
		data.SourceMediaType	= isDrive;
        data.SourceDir		      = DriveList->GetDrivePath (gtk_combo_box_get_active (GTK_COMBO_BOX(InputCobobox)));
	}else{
		alert ("Error: unknown media type");
		return FALSE;
	}


	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(OutputFileRadioButton))){
		data.DestinationMediaType	= isFile;
		data.Destination		= gtk_entry_get_text (GTK_ENTRY (OutputFileEntry));

		if (data.Destination.size() == 0){
			alert ("Error: incorrect output filename");
			return FALSE;
		}

		// Check if a file is overwritten and ask if this is allowed if needed :)
		if( g_file_test(data.Destination.c_str(), G_FILE_TEST_EXISTS) ){
			GtkWidget *msgdlg	= NULL;
			msgdlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, "File already exists, do you want to overwrite?");
			if (gtk_dialog_run(GTK_DIALOG(msgdlg)) == GTK_RESPONSE_NO){
				gtk_widget_destroy(msgdlg);
				return FALSE;
			}
			gtk_widget_destroy(msgdlg);
		}

		// Check if the output file is not a directory
		if (g_file_test(data.Destination.c_str(), G_FILE_TEST_IS_DIR) ){
			alert ("Error: output file is a directory");
			return FALSE;
		}

	}else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(OutputDriveRadioButton))){
		data.DestinationMediaType	= isDrive;
		data.Destination	         = DriveList->GetDrivePath (gtk_combo_box_get_active (GTK_COMBO_BOX(OutputCobobox)));

        // Ask if the data on this drive may be overwritten
        GtkWidget *msgdlg	= NULL;
		msgdlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, "All data on the destination drive will be lost, do you want to continue?");
		if (gtk_dialog_run(GTK_DIALOG(msgdlg)) == GTK_RESPONSE_NO){
			gtk_widget_destroy(msgdlg);
			return FALSE;
		}
		gtk_widget_destroy(msgdlg);
	}else{
		alert ("Error: unknown media type");
		return FALSE;
	}

	// Setup the input and output path labels
	InputPathLabelString	= "Input:\t\t\t";
	InputPathLabelString	+= data.SourceDir;
	OutputPathLabelString	= "Output:\t\t\t";
	OutputPathLabelString	+= data.Destination;
	gtk_label_set_label((GtkLabel *)StatusInputPathLabel, InputPathLabelString.c_str());
	gtk_label_set_label((GtkLabel *)StatusOutputPathLabel, OutputPathLabelString.c_str());

	// Show the Status frame
	gtk_widget_show (StatusFrame);
	gtk_widget_hide (InputFrame);
	gtk_widget_hide (ProcessingFrame);
	gtk_widget_hide (OutputFrame);
	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pbar), 0);


	// Setup the args for the copy thread
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(DeCompressSourceRadioButton)))
		data.InflateSource	= true;
	else
		data.InflateSource	= false;

	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(CompressImageRadioButton))){
		if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(GzipFastRadioButton)))
			data.CompressionMethod	= Z_BEST_SPEED;
		else
			data.CompressionMethod	= Z_BEST_COMPRESSION;
	}else{
		data.CompressionMethod		= 0;
	}

	// Setup the args for the progress status display
	CopyThreadDone         = false;
	Info.BytesRead         = 0;
	Info.BytesWritten      = 0;
	Info.WriteThreadError  = ERROR_WRITETHREAD_NONE;
	Info.ReadThreadError   = ERROR_READTHREAD_NONE;

	gtk_widget_set_sensitive (OkeButton, false);

	// Start the copy thread
	if( (CopyThread = g_thread_create((GThreadFunc)CopyData, (void *)&data, TRUE, &error)) == NULL)
	{
		printf("Thread create failed: %s!!\n", error->message );
		g_error_free ( error ) ;
	}

    return handle_update_progress ();
}
void pawsPetitionGMWindow::HandleMessage ( MsgEntry* me )
{
    //printf("Incomming Petition GM Petition Message\n");
    // Get the petition message data from the server
    psPetitionMessage message(me);

    if (!message.isGM)
    {
        //printf("Bailing out because of message.isGM");
        return;
    }

    if (message.msgType == PETITION_DIRTY && psengine->GetCelClient()->GetMainPlayer()->GetType() > 20)
    {
        if (hasPetInterest)
        {
            //printf("Looking for pet interest and bailing out\n");
            QueryServer();
        }
        return;
    }

    // if the server gave us a list of petitions, then use it
//    if (message.petitions.GetSize() > 0)
    petitionMessage = message;

    // Check if server reported errors on the query
    if (!message.success)
    {
        printf("Message was not a success\n");
        psSystemMessage error(0,MSG_INFO,message.error);
        msgqueue->Publish(error.msg);

        QueryServer(); //request the server a new petition list
        return;
    }

    // Check no petitions:
    if (message.petitions.GetSize() == 0)
    {
        //printf("No petitions in list\n");
        petCount = 0;
        petitionList->Clear();
        petitionList->NewRow(0);
        SetText(0, 1, PawsManager::GetSingleton().Translate("No Petitions"));
        return;
    }

    // Check its type (list, confirm, or assign):
    if (message.msgType == PETITION_CANCEL || message.msgType == PETITION_CLOSE)
    {
        // Check if server reported errors on the query
        if (!message.success)
        {
            printf("!message.succss\n");
            psSystemMessage error(0,MSG_INFO,message.error);
            msgqueue->Publish(error.msg);
            return;
        }

        // Change the status of the position we wanted to cancel:
        if (currentRow < 0)
        {
            // This should NEVER happen (it means the server gave a bogus message)
            Error1("PetitionGMWindow reports invalid currentRow!");
            printf("Invalid currentRow\n");
            return;
        }

        // Remove the item and refresh the list:
//        petitionMessage.petitions.DeleteIndex(currentRow);

        AddPetitions(petitionMessage.petitions);

        petitionList->Select(petitionList->GetRow(currentRow));

        csString report;
        csString translation1 = PawsManager::GetSingleton().Translate("The selected petition was %s");
        csString translation2 = PawsManager::GetSingleton().Translate(message.msgType == PETITION_CANCEL ? "cancelled.":"closed.");
        report.Format(translation1.GetData(), translation2.GetData());
        psSystemMessage confirm(0,MSG_INFO,report.GetData());
        msgqueue->Publish(confirm.msg);


        return;
    }

    if (message.msgType == PETITION_ASSIGN)
    {
        // Check if server reported errors on the query
        if (!message.success)
        {
            printf("Assign fail\n");
            psSystemMessage error(0,MSG_INFO,message.error);
            msgqueue->Publish(error.msg);
            return;
        }

        // Change the status of the position we wanted to assign:
        if (currentRow < 0)
        {
            printf("Bad row\n");
            // This should NEVER happen (it means the server gave a bogus message)
            Error1("PetitionGMWindow reports invalid currentRow!");
            return;
        }

        // Change the status of the item in the list box:
//        petitionMessage.petitions.Get(currentRow).status = "In Progress";
        AddPetitions(petitionMessage.petitions);

        psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("You have been assigned to the selected petition."));
        msgqueue->Publish(confirm.msg);

        return;
    }

    if (message.msgType == PETITION_DEASSIGN)
    {
        // Check if server reported errors on the query
        if (!message.success)
        {
            printf("dessign fail\n");
            psSystemMessage error(0,MSG_INFO,message.error);
            msgqueue->Publish(error.msg);
            return;
        }

        // Change the status of the position we wanted to assign:
        if (currentRow < 0)
        {
            printf("Bad row\n");
            // This should NEVER happen (it means the server gave a bogus message)
            Error1("PetitionGMWindow reports invalid currentRow!");
            return;
        }

        // Change the status of the item in the list box:
        AddPetitions(petitionMessage.petitions);

        psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("You have been deassigned from the selected petition."));
        msgqueue->Publish(confirm.msg);

        return;
    }

    if (message.msgType == PETITION_ESCALATE)
    {
        //printf("Escalate\n");
        // Check if server reported errors on the query
        if (!message.success)
        {
            psSystemMessage error(0,MSG_INFO,message.error);
            msgqueue->Publish(error.msg);
            return;
        }

        // Change the status of the position we wanted to assign:
        if (currentRow < 0)
        {
            // This should NEVER happen (it means the server gave a bogus message)
            Error1("PetitionGMWindow reports invalid currentRow!");
            return;
        }

        // Change the status of the item in the list box:
//        petitionMessage.petitions.Get(currentRow).escalation += 1;
//        petitionMessage.petitions.Get(currentRow).status = "Open";
        AddPetitions(petitionMessage.petitions);

        psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("The selected petition has been escalated."));
        msgqueue->Publish(confirm.msg);

        return;
    }
    if (message.msgType == PETITION_DESCALATE)
    {
        //printf("Descalate\n");
        // Check if server reported errors on the query
        if (!message.success)
        {
            psSystemMessage error(0,MSG_INFO,message.error);
            msgqueue->Publish(error.msg);
            return;
        }

        // Change the status of the position we wanted to assign:
        if (currentRow < 0)
        {
            // This should NEVER happen (it means the server gave a bogus message)
            Error1("PetitionGMWindow reports invalid currentRow!");
            return;
        }

        // Change the status of the item in the list box:
        AddPetitions(petitionMessage.petitions);

        psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("The selected petition has been descalated."));
        msgqueue->Publish(confirm.msg);

        return;
    }

    // Update the listbox:
    int tempCount = petCount;
    AddPetitions(message.petitions);
    petitionList->SortRows();   ///sort the column specified in xml

    //alert GM that there are petitions waiting
    if (tempCount == -1)
    {
        csString message = PawsManager::GetSingleton().Translate("There are ");
        message += petCount;
        message += PawsManager::GetSingleton().Translate(" unanswered petitions."); //make a nice message

        psSystemMessage alert(0,MSG_INFO,message); //and send it
        msgqueue->Publish(alert.msg);
    }
    else if (petCount > tempCount)
    {
        psPetitionInfo info = message.petitions.Get(petCount-1); //get the last petition (supposed to be the new one)
        csString message = PawsManager::GetSingleton().Translate("New petition from ") + info.player.GetDataSafe(); //make a nice message

        psSystemMessage alert(0,MSG_INFO,message); //and send it
        msgqueue->Publish(alert.msg);
    }
}
Exemplo n.º 27
0
void never() {
  EM_ASM({ alert('this should never be reached! runtime must not be shut down!') });
  assert(0);
  while (1) {}
}
Exemplo n.º 28
0
void System::runMain(const char *mainBasPath) {
  logEntered();

  // activePath provides the program name after termination
  String activePath = mainBasPath;
  _loadPath = mainBasPath;
  _mainBas = true;
  strcpy(opt_command, "welcome");

  bool started = execute(_loadPath);
  if (!started) {
    alert("Error", gsb_last_errmsg);
    _state = kClosingState;
  }

  while (!isClosing() && started) {
    if (isRestart()) {
      _loadPath = activePath;
      _state = kActiveState;
    } else {
      if (fileExists(_loadPath)) {
        _mainBas = false;
        activePath = _loadPath;
        if (!isEditReady()) {
          setupPath(_loadPath);
        }
      } else {
        _mainBas = true;
        _loadPath = mainBasPath;
        activePath = mainBasPath;
      }
    }

    if (!_mainBas && isEditReady() && loadSource(_loadPath)) {
      editSource(_loadPath);
      if (isBack()) {
        _loadPath.clear();
        _state = kActiveState;
        continue;
      } else if (isClosing()) {
        break;
      }
    }

    bool success = execute(_loadPath);
    bool networkFile = isNetworkLoad();
    if (!isBack() && !isClosing() &&
        (success || networkFile || !isEditEnabled())) {
      // when editing, only pause here when successful, otherwise the editor shows
      // the error. load the next network file without displaying the previous result
      if (!_mainBas && !networkFile) {
        // display an indication the program has completed
        showCompletion(success);
      }
      if (!success) {
        if (_mainBas) {
          // unexpected error in main.bas
          alert("", gsb_last_errmsg);
          _state = kClosingState;
        } else {
          // don't reload
          _loadPath.clear();
          _state = kActiveState;
        }
      }
      if (!_mainBas && !networkFile) {
        waitForBack();
      }
    }
  }
}
Exemplo n.º 29
0
int
main(int argc, char **argv)
{
	BITMAP *bmp = NULL;
	int x, y, mx, my;
	int result, mode = GFX_AUTODETECT;

	allegro_init();
	install_keyboard();

	if (install_mouse() < 0) {
		allegro_message("This example requires a mouse to run!");
		return -1;
	}

	jpgalleg_init();

	if (cpu_capabilities & CPU_MMX)
		popup_menu[2].flags = D_SELECTED;

	if ((argc > 1) && (!strcmp(argv[1], "-window")))
		mode = GFX_AUTODETECT_WINDOWED;

	set_color_depth(32);
	if (set_gfx_mode(mode, 640, 480, 0, 0)) {
		set_color_depth(16);
		if (set_gfx_mode(mode, 640, 480, 0, 0)) {
			set_color_depth(15);
			if (set_gfx_mode(mode, 640, 480, 0, 0)) {
				allegro_message("Unable to init truecolor 640x480 gfx mode: %s", allegro_error);
				return -1;
			}
		}
	}

	clear_to_color(screen, gui_mg_color);
	show_mouse(screen);
	
	alert("JPG image load/save example for " JPGALLEG_VERSION_STRING, NULL, "Press right mouse button for contextual menu, ESC to quit.", "Ok", NULL, 0, 0);

	while (!key[KEY_ESC]) {
		x = mouse_x;
		y = mouse_y;
		get_mouse_mickeys(&mx, &my);
		mx /= 2;
		my /= 2;

		bmp = settings_dialog[PREVIEW].dp;

		if (bmp) {
			old_sx = sx;
			old_sy = sy;
			if (bmp->w > SCREEN_W) {
				if ((x == 0) && (mx < 0) && (sx > 0))
					sx = MAX(0, sx + mx);
				if ((x == SCREEN_W - 1) && (mx > 0) && (sx < bmp->w - SCREEN_W - 1))
					sx = MIN(sx + mx, bmp->w - SCREEN_W - 1);
				if (key[KEY_LEFT] && (sx > 0))
					sx = MAX(0, sx - 8);
				if (key[KEY_RIGHT] && (sx < bmp->w - SCREEN_W - 1))
					sx = MIN(sx + 8, bmp->w - SCREEN_W - 1);
			}
			if (bmp->h > SCREEN_H) {
				if ((y == 0) && (my < 0) && (sy > 0))
					sy = MAX(0, sy + my);
				if ((y == SCREEN_H - 1) && (my > 0) && (sy < bmp->h - SCREEN_H - 1))
					sy = MIN(sy + my, bmp->h - SCREEN_H - 1);
				if (key[KEY_UP] && (sy > 0))
					sy = MAX(0, sy - 8);
				if (key[KEY_DOWN] && (sy < bmp->h - SCREEN_H - 1))
					sy = MIN(sy + 8, bmp->h - SCREEN_H - 1);
			}
			if ((sx != old_sx) || (sy != old_sy))
				draw_image(bmp, sx, sy);
		}
		if (mouse_b & 0x2) {
			result = do_menu(popup_menu, x, y);
			while(key[KEY_ESC])
				;
			if (result == 3)
				break;
			draw_image((BITMAP *)settings_dialog[PREVIEW].dp, sx, sy);
		}
	}

	if (bmp)
		destroy_bitmap(bmp);

	return 0;
}
Exemplo n.º 30
0
void ObjDetect::emit_alert ( const QString & msg )
{
    emit alert ( msg );
}