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::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::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