long CMUSHclientDoc::GetTimer(LPCTSTR TimerName, VARIANT FAR* Hour, VARIANT FAR* Minute, VARIANT FAR* Second, VARIANT FAR* ResponseText, VARIANT FAR* Flags, VARIANT FAR* ScriptName) { CString strTimerName = TimerName; CTimer * timer_item; // trim spaces from name, make lower-case CheckObjectName (strTimerName, false); if (!GetTimerMap ().Lookup (strTimerName, timer_item)) return eTimerNotFound; if (timer_item->iType == CTimer::eAtTime) { SetUpVariantShort (*Hour, timer_item->iAtHour); SetUpVariantShort (*Minute, timer_item->iAtMinute); SetUpVariantDouble (*Second, timer_item->fAtSecond); } else { SetUpVariantShort (*Hour, timer_item->iEveryHour); SetUpVariantShort (*Minute, timer_item->iEveryMinute); SetUpVariantDouble (*Second, timer_item->fEverySecond); } SetUpVariantString (*ResponseText, timer_item->strContents); SetUpVariantString (*ScriptName, timer_item->strProcedure); short iFlags = 0; if (timer_item->bEnabled) iFlags |= eEnabled; if (timer_item->bOneShot) iFlags |= eOneShot; if (timer_item->iSendTo == eSendToSpeedwalk) iFlags |= eTimerSpeedWalk; if (timer_item->iSendTo == eSendToOutput) iFlags |= eTimerNote; if (timer_item->bActiveWhenClosed) iFlags |= eActiveWhenClosed; SetUpVariantShort (*Flags, iFlags); return eOK; } // end of CMUSHclientDoc::GetTimer
long CMUSHclientDoc::GetTrigger(LPCTSTR TriggerName, VARIANT FAR* MatchText, VARIANT FAR* ResponseText, VARIANT FAR* Flags, VARIANT FAR* Colour, VARIANT FAR* Wildcard, VARIANT FAR* SoundFileName, VARIANT FAR* ScriptName) { CString strTriggerName = TriggerName; CTrigger * trigger_item; // trim spaces from name, make lower-case CheckObjectName (strTriggerName, false); if (!GetTriggerMap ().Lookup (strTriggerName, trigger_item)) return eTriggerNotFound; SetUpVariantString (*MatchText, trigger_item->trigger); SetUpVariantString (*ResponseText, trigger_item->contents); SetUpVariantString (*ScriptName, trigger_item->strProcedure); SetUpVariantString (*SoundFileName, trigger_item->sound_to_play); SetUpVariantShort (*Colour, trigger_item->colour); if (trigger_item->colour == SAMECOLOUR) SetUpVariantShort (*Colour, -1); short iFlags = 0; if (trigger_item->ignore_case) iFlags |= eIgnoreCase; if (trigger_item->bOmitFromOutput) iFlags |= eOmitFromOutput; if (trigger_item->bKeepEvaluating) iFlags |= eKeepEvaluating; if (trigger_item->omit_from_log) iFlags |= eOmitFromOutput; if (trigger_item->bEnabled) iFlags |= eEnabled; if (trigger_item->bRegexp) iFlags |= eTriggerRegularExpression; if (trigger_item->bLowercaseWildcard) iFlags |= eLowercaseWildcard; if (trigger_item->bOneShot) iFlags |= eTriggerOneShot; SetUpVariantShort (*Flags, iFlags); SetUpVariantShort (*Wildcard, trigger_item->iClipboardArg); return eOK; } // end of CMUSHclientDoc::GetTrigger
VARIANT CMUSHclientDoc::GetCurrentValue(LPCTSTR OptionName) { VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; // default if not found int i = GetOptionIndex (OptionName); if (i != -1) { if (m_CurrentPlugin && (OptionsTable [i].iFlags & OPT_PLUGIN_CANNOT_READ)) return vaResult; // not available to plugin SetUpVariantLong (vaResult, GetOptionItem (i)); } // end of found else { i = GetAlphaOptionIndex (OptionName); if (i != -1) { if (m_CurrentPlugin && (AlphaOptionsTable [i].iFlags & OPT_PLUGIN_CANNOT_READ)) return vaResult; // not available to plugin SetUpVariantString (vaResult, GetAlphaOptionItem (i)); } // end of found } return vaResult; } // end of CMUSHclientDoc::GetCurrentValue
VARIANT CMUSHclientDoc::GetTriggerWildcard(LPCTSTR TriggerName, LPCTSTR WildcardName) { CString strTriggerName = TriggerName; CTrigger * trigger_item; VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; // trim spaces from name, make lower-case CheckObjectName (strTriggerName, false); vaResult.vt = VT_EMPTY; // see if trigger exists, if not return EMPTY if (!GetTriggerMap ().Lookup (strTriggerName, trigger_item)) return vaResult; if (WildcardName [0] != 0 && trigger_item->regexp) { CString strResult = trigger_item->regexp->GetWildcard (WildcardName).c_str (); SetUpVariantString (vaResult, strResult); } return vaResult; } // end of CMUSHclientDoc::GetTriggerWildcard
VARIANT CMUSHclientDoc::GenerateName() { VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; // if no names file read, return NULL variant if (!bNamesRead) return vaResult; CString strName = ::GenerateName (); SetUpVariantString (vaResult, strName); return vaResult; } // end of CMUSHclientDoc::GenerateName
VARIANT CMUSHclientDoc::GetAlphaOption(LPCTSTR OptionName) { VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_EMPTY; long i = GetAlphaOptionIndex (OptionName); if (i == -1) return vaResult; if (m_CurrentPlugin && (AlphaOptionsTable [i].iFlags & OPT_PLUGIN_CANNOT_READ)) return vaResult; // not available to plugin SetUpVariantString (vaResult, GetAlphaOptionItem (i)); return vaResult; }
VARIANT CMUSHclientDoc::Base64Encode(LPCTSTR Text, BOOL MultiLine) { VARIANT vaResult; VariantInit(&vaResult); CString strResult; try { strResult = encodeBase64 (Text, MultiLine); } // end of try catch(CException* e) { e->Delete (); vaResult.vt = VT_NULL; return vaResult; } // end of catch SetUpVariantString (vaResult, strResult); return vaResult; } // end of CMUSHclientDoc::Base64Encode
VARIANT CMUSHclientDoc::SpellCheckDlg(LPCTSTR Text) { VARIANT vaResult; VariantInit(&vaResult); if (!App.m_bSpellCheckOK) return vaResult; if (App.m_SpellChecker_Lua) { lua_settop(App.m_SpellChecker_Lua, 0); // clear stack lua_getglobal (App.m_SpellChecker_Lua, SPELLCHECKFUNCTION); if (!lua_isfunction (App.m_SpellChecker_Lua, -1)) return vaResult; // cannot spell check string lua_pushstring (App.m_SpellChecker_Lua, Text); // string to be checked int narg = lua_gettop(App.m_SpellChecker_Lua) - 1; // all but the function int error = CallLuaWithTraceBack (App.m_SpellChecker_Lua, narg, 1); if (error) { LuaError (App.m_SpellChecker_Lua, "Run-time error", SPELLCHECKFUNCTION, "world.SpellCheckDlg", "", this); return vaResult; // cannot spell check string - syntax error or dialog cancelled } // must be string or else return bad result if (!lua_isstring (App.m_SpellChecker_Lua, -1)) return vaResult; // shouldn't happen? maybe dialog cancelled SetUpVariantString (vaResult, lua_tostring (App.m_SpellChecker_Lua, -1)); } return vaResult; } // end of CMUSHclientDoc::SpellCheckDlg
VARIANT CMUSHclientDoc::GetTriggerOption(LPCTSTR TriggerName, LPCTSTR OptionName) { CString strTriggerName = TriggerName; CTrigger * trigger_item; VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; // trim spaces from name, make lower-case CheckObjectName (strTriggerName, false); vaResult.vt = VT_EMPTY; // see if trigger exists, if not return EMPTY if (!GetTriggerMap ().Lookup (strTriggerName, trigger_item)) return vaResult; int iItem; int iResult = FindBaseOption (OptionName, TriggerOptionsTable, iItem); if (iResult == eOK) { // numeric option if (m_CurrentPlugin && (TriggerOptionsTable [iItem].iFlags & OPT_PLUGIN_CANNOT_READ)) return vaResult; // not available to plugin long Value = GetBaseOptionItem (iItem, TriggerOptionsTable, NUMITEMS (TriggerOptionsTable), (char *) trigger_item); SetUpVariantLong (vaResult, Value); } // end of found numeric option else { // not numeric option, try alpha int iResult = FindBaseAlphaOption (OptionName, TriggerAlphaOptionsTable, iItem); if (iResult == eOK) { // alpha option if (m_CurrentPlugin && (TriggerAlphaOptionsTable [iItem].iFlags & OPT_PLUGIN_CANNOT_READ)) return vaResult; // not available to plugin CString strValue = GetBaseAlphaOptionItem (iItem, TriggerAlphaOptionsTable, NUMITEMS (TriggerAlphaOptionsTable), (char *) trigger_item); SetUpVariantString (vaResult, strValue); } // end of found } return vaResult; } // end of GetTriggerOption
VARIANT CMUSHclientDoc::GetTriggerInfo(LPCTSTR TriggerName, short InfoType) { CString strTriggerName = TriggerName; CTrigger * trigger_item; VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; // trim spaces from name, make lower-case CheckObjectName (strTriggerName, false); vaResult.vt = VT_EMPTY; // see if trigger exists, if not return EMPTY if (!GetTriggerMap ().Lookup (strTriggerName, trigger_item)) return vaResult; switch (InfoType) { case 1: SetUpVariantString (vaResult, trigger_item->trigger); break; case 2: SetUpVariantString (vaResult, trigger_item->contents); break; case 3: SetUpVariantString (vaResult, trigger_item->sound_to_play); break; case 4: SetUpVariantString (vaResult, trigger_item->strProcedure); break; case 5: SetUpVariantBool (vaResult, trigger_item->omit_from_log); break; case 6: SetUpVariantBool (vaResult, trigger_item->bOmitFromOutput); break; case 7: SetUpVariantBool (vaResult, trigger_item->bKeepEvaluating); break; case 8: SetUpVariantBool (vaResult, trigger_item->bEnabled); break; case 9: SetUpVariantBool (vaResult, trigger_item->bRegexp); break; case 10: SetUpVariantBool (vaResult, trigger_item->ignore_case); break; case 11: SetUpVariantBool (vaResult, trigger_item->bRepeat); break; case 12: SetUpVariantBool (vaResult, trigger_item->bSoundIfInactive); break; case 13: SetUpVariantBool (vaResult, trigger_item->bExpandVariables); break; case 14: SetUpVariantShort (vaResult, trigger_item->iClipboardArg); break; case 15: SetUpVariantShort (vaResult, trigger_item->iSendTo); break; case 16: SetUpVariantShort (vaResult, trigger_item->iSequence); break; case 17: SetUpVariantShort (vaResult, trigger_item->iMatch); break; case 18: SetUpVariantShort (vaResult, trigger_item->iStyle); break; case 19: SetUpVariantShort (vaResult, trigger_item->colour); break; case 20: SetUpVariantLong (vaResult, trigger_item->nInvocationCount); break; case 21: SetUpVariantLong (vaResult, trigger_item->nMatched); break; case 22: if (trigger_item->tWhenMatched.GetTime ()) // only if non-zero, otherwise return empty SetUpVariantDate (vaResult, COleDateTime (trigger_item->tWhenMatched.GetTime ())); break; case 23: SetUpVariantBool (vaResult, trigger_item->bTemporary); break; case 24: SetUpVariantBool (vaResult, trigger_item->bIncluded); break; case 25: SetUpVariantBool (vaResult, trigger_item->bLowercaseWildcard); break; case 26: SetUpVariantString (vaResult, trigger_item->strGroup); break; case 27: SetUpVariantString (vaResult, trigger_item->strVariable); break; case 28: SetUpVariantLong (vaResult, trigger_item->iUserOption); break; case 29: SetUpVariantLong (vaResult, trigger_item->iOtherForeground); break; case 30: SetUpVariantLong (vaResult, trigger_item->iOtherBackground); break; case 31: // number of matches to regexp if (trigger_item->regexp) SetUpVariantLong (vaResult, trigger_item->regexp->m_iCount); else SetUpVariantLong (vaResult, 0); break; case 32: // last matching string if (trigger_item->regexp) SetUpVariantString (vaResult, trigger_item->regexp->m_sTarget.c_str ()); else SetUpVariantString (vaResult, ""); break; case 33: SetUpVariantBool (vaResult, trigger_item->bExecutingScript); break; case 34: SetUpVariantBool (vaResult, trigger_item->dispid != DISPID_UNKNOWN); break; case 35: if (trigger_item->regexp && trigger_item->regexp->m_program == NULL) SetUpVariantLong (vaResult, trigger_item->regexp->m_iExecutionError); else SetUpVariantLong (vaResult, 0); break; case 36: SetUpVariantBool (vaResult, trigger_item->bOneShot); break; case 37: if (trigger_item->regexp && App.m_iCounterFrequency) { double elapsed_time; elapsed_time = ((double) trigger_item->regexp->iTimeTaken) / ((double) App.m_iCounterFrequency); SetUpVariantDouble (vaResult, elapsed_time); } break; case 38: if (trigger_item->regexp) SetUpVariantLong (vaResult, trigger_item->regexp->m_iMatchAttempts); break; #ifdef PANE case 38: SetUpVariantString (vaResult, trigger_item->strPane); break; #endif // PANE case 101: SetUpVariantString (vaResult, trigger_item->wildcards [1].c_str ()); break; case 102: SetUpVariantString (vaResult, trigger_item->wildcards [2].c_str ()); break; case 103: SetUpVariantString (vaResult, trigger_item->wildcards [3].c_str ()); break; case 104: SetUpVariantString (vaResult, trigger_item->wildcards [4].c_str ()); break; case 105: SetUpVariantString (vaResult, trigger_item->wildcards [5].c_str ()); break; case 106: SetUpVariantString (vaResult, trigger_item->wildcards [6].c_str ()); break; case 107: SetUpVariantString (vaResult, trigger_item->wildcards [7].c_str ()); break; case 108: SetUpVariantString (vaResult, trigger_item->wildcards [8].c_str ()); break; case 109: SetUpVariantString (vaResult, trigger_item->wildcards [9].c_str ()); break; case 110: SetUpVariantString (vaResult, trigger_item->wildcards [0].c_str ()); break; default: vaResult.vt = VT_NULL; break; } // end of switch return vaResult; } // end of CMUSHclientDoc::GetTriggerInfo
VARIANT CMUSHclientDoc::GetPluginInfo(LPCTSTR PluginID, short InfoType) { VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; CPlugin * pPlugin = GetPlugin (PluginID); if (!pPlugin) return vaResult; // plugin not found switch (InfoType) { case 1: SetUpVariantString (vaResult, pPlugin->m_strName); break; case 2: SetUpVariantString (vaResult, pPlugin->m_strAuthor); break; case 3: SetUpVariantString (vaResult, pPlugin->m_strDescription); break; case 4: SetUpVariantString (vaResult, pPlugin->m_strScript); break; case 5: SetUpVariantString (vaResult, pPlugin->m_strLanguage); break; case 6: SetUpVariantString (vaResult, pPlugin->m_strSource); break; case 7: SetUpVariantString (vaResult, pPlugin->m_strID); break; case 8: SetUpVariantString (vaResult, pPlugin->m_strPurpose); break; case 9: SetUpVariantLong (vaResult, pPlugin->m_TriggerMap.GetCount ()); break; case 10: SetUpVariantLong (vaResult, pPlugin->m_AliasMap.GetCount ()); break; case 11: SetUpVariantLong (vaResult, pPlugin->m_TimerMap.GetCount ()); break; case 12: SetUpVariantLong (vaResult, pPlugin->m_VariableMap.GetCount ()); break; case 13: if (pPlugin->m_tDateWritten.GetTime ()) // only if non-zero, otherwise return empty SetUpVariantDate (vaResult, COleDateTime (pPlugin->m_tDateWritten.GetTime ())); break; case 14: if (pPlugin->m_tDateModified.GetTime ()) // only if non-zero, otherwise return empty SetUpVariantDate (vaResult, COleDateTime (pPlugin->m_tDateModified.GetTime ())); break; case 15: SetUpVariantBool (vaResult, pPlugin->m_bSaveState); break; // 16: is scripting enabled? case 16: SetUpVariantBool (vaResult, pPlugin->m_ScriptEngine != NULL); break; case 17: SetUpVariantBool (vaResult, pPlugin->m_bEnabled); break; case 18: SetUpVariantDouble (vaResult, pPlugin->m_dRequiredVersion); break; case 19: SetUpVariantDouble (vaResult, pPlugin->m_dVersion); break; case 20: SetUpVariantString (vaResult, pPlugin->m_strDirectory); break; case 21: { int iCount = 0; // first work out what order each plugin is in *now* for (PluginListIterator pit = m_PluginList.begin (); pit != m_PluginList.end (); ++pit) (*pit)->m_iLoadOrder = ++iCount; // now return the order of *this* one SetUpVariantLong (vaResult, pPlugin->m_iLoadOrder); } break; case 22: SetUpVariantDate (vaResult, COleDateTime (pPlugin->m_tDateInstalled.GetTime ())); break; case 23: SetUpVariantString (vaResult, pPlugin->m_strCallingPluginID); break; case 24: { double elapsed_time = 0.0; if (App.m_iCounterFrequency > 0) elapsed_time = ((double) pPlugin->m_iScriptTimeTaken) / ((double) App.m_iCounterFrequency); SetUpVariantDouble (vaResult, elapsed_time); break; } default: vaResult.vt = VT_NULL; break; } // end of switch return vaResult; } // end of CMUSHclientDoc::GetPluginInfo
VARIANT CMUSHclientDoc::GetTimerOption(LPCTSTR TimerName, LPCTSTR OptionName) { CString strTimerName = TimerName; CTimer * Timer_item; VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; // trim spaces from name, make lower-case CheckObjectName (strTimerName, false); vaResult.vt = VT_EMPTY; // see if Timer exists, if not return EMPTY if (!GetTimerMap ().Lookup (strTimerName, Timer_item)) return vaResult; CString strOptionName = OptionName; strOptionName.MakeLower(); strOptionName.TrimLeft (); strOptionName.TrimRight (); int iItem; int iResult = FindBaseOption (strOptionName, TimerOptionsTable, iItem); if (iResult == eOK) { // numeric option if (m_CurrentPlugin && (TimerOptionsTable [iItem].iFlags & OPT_PLUGIN_CANNOT_READ)) return vaResult; // not available to plugin double Value; // this is a pest! if (strOptionName == "hour") { if (Timer_item->iType == CTimer::eInterval) Value = Timer_item->iEveryHour; else Value = Timer_item->iAtHour; } // end of option "hour" else if (strOptionName == "minute") { if (Timer_item->iType == CTimer::eInterval) Value = Timer_item->iEveryMinute; else Value = Timer_item->iAtMinute; } // end of option "minute" else if (strOptionName == "second") { if (Timer_item->iType == CTimer::eInterval) Value = Timer_item->fEverySecond; else Value = Timer_item->fAtSecond; } // end of option "second" else Value = GetBaseOptionItem (iItem, TimerOptionsTable, NUMITEMS (TimerOptionsTable), (char *) Timer_item); SetUpVariantDouble (vaResult, Value); } // end of found numeric option else { // not numeric option, try alpha int iResult = FindBaseAlphaOption (OptionName, TimerAlphaOptionsTable, iItem); if (iResult == eOK) { // alpha option if (m_CurrentPlugin && (TimerAlphaOptionsTable [iItem].iFlags & OPT_PLUGIN_CANNOT_READ)) return vaResult; // not available to plugin CString strValue = GetBaseAlphaOptionItem (iItem, TimerAlphaOptionsTable, NUMITEMS (TimerAlphaOptionsTable), (char *) Timer_item); SetUpVariantString (vaResult, strValue); } // end of found } return vaResult; } // end of GetTimerOption
VARIANT CMUSHclientDoc::GetTimerInfo(LPCTSTR TimerName, short InfoType) { CString strTimerName = TimerName; CTimer * timer_item; VARIANT vaResult; VariantInit(&vaResult); vaResult.vt = VT_NULL; // trim spaces from name, make lower-case CheckObjectName (strTimerName, false); vaResult.vt = VT_EMPTY; // see if timer exists, if not return EMPTY if (!GetTimerMap ().Lookup (strTimerName, timer_item)) return vaResult; switch (InfoType) { case 1: if (timer_item->iType == CTimer::eAtTime) SetUpVariantShort (vaResult, timer_item->iAtHour); else SetUpVariantShort (vaResult, timer_item->iEveryHour); break; case 2: if (timer_item->iType == CTimer::eAtTime) SetUpVariantShort (vaResult, timer_item->iAtMinute); else SetUpVariantShort (vaResult, timer_item->iEveryMinute); break; case 3: if (timer_item->iType == CTimer::eAtTime) SetUpVariantDouble (vaResult, timer_item->fAtSecond); else SetUpVariantDouble (vaResult, timer_item->fEverySecond); break; case 4: SetUpVariantString (vaResult, timer_item->strContents); break; case 5: SetUpVariantString (vaResult, timer_item->strProcedure); break; case 6: SetUpVariantBool (vaResult, timer_item->bEnabled); break; case 7: SetUpVariantBool (vaResult, timer_item->bOneShot); break; case 8: SetUpVariantBool (vaResult, timer_item->iType == CTimer::eAtTime); break; case 9: SetUpVariantLong (vaResult, timer_item->nInvocationCount); break; case 10: SetUpVariantLong (vaResult, timer_item->nMatched); break; case 11: if (timer_item->tWhenFired.GetTime ()) // only if non-zero, otherwise return empty SetUpVariantDate (vaResult, COleDateTime (timer_item->tWhenFired.GetTime ())); break; case 12: if (timer_item->tFireTime.GetTime ()) // only if non-zero, otherwise return empty SetUpVariantDate (vaResult, COleDateTime (timer_item->tFireTime.GetTime ())); break; case 13: { CmcDateTime tDue = CmcDateTime (timer_item->tFireTime.GetTime ()); CmcDateTime tNow = CmcDateTime::GetTimeNow (); if (tDue < tNow) SetUpVariantDouble (vaResult, 0); // due immediately else { CmcDateTimeSpan ts = tDue - tNow; SetUpVariantDouble (vaResult, ts.GetTotalSeconds ()); // how many seconds to go } } break; case 14: SetUpVariantBool (vaResult, timer_item->bTemporary); break; case 15: SetUpVariantBool (vaResult, timer_item->iSendTo == eSendToSpeedwalk); break; case 16: SetUpVariantBool (vaResult, timer_item->iSendTo == eSendToOutput); break; case 17: SetUpVariantBool (vaResult, timer_item->bActiveWhenClosed); break; case 18: SetUpVariantBool (vaResult, timer_item->bIncluded); break; case 19: SetUpVariantString (vaResult, timer_item->strGroup); break; case 20: SetUpVariantLong (vaResult, timer_item->iSendTo); break; case 21: SetUpVariantLong (vaResult, timer_item->iUserOption); break; case 22: SetUpVariantString (vaResult, timer_item->strLabel); break; case 23: SetUpVariantBool (vaResult, timer_item->bOmitFromOutput); break; case 24: SetUpVariantBool (vaResult, timer_item->bOmitFromLog); break; case 25: SetUpVariantBool (vaResult, timer_item->bExecutingScript); break; case 26: SetUpVariantBool (vaResult, timer_item->dispid != DISPID_UNKNOWN); break; default: vaResult.vt = VT_NULL; break; } // end of switch return vaResult; } // end of CMUSHclientDoc::GetTimerInfo