Changeset 5987 for branches/newosd
- Timestamp:
- 01/04/08 03:49:52 (11 months ago)
- Location:
- branches/newosd/src
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/newosd/src/conf.cpp
r5984 r5987 18 18 cleanup(); 19 19 20 CIniFile conf(INI_Fx WARN);20 CIniFile conf(INI_FxALLOWxCREATE | INI_FxERROR); 21 21 if (!conf.LoadFile(file.c_str())) 22 { 23 conf.SetFlags(INI_FxALLOWxCREATE); 24 if (!conf.ReloadFile()) 25 return; 26 conf.CreateSection("Appearance"); 27 conf.CreateSection("Colouring"); 28 conf.CreateSection("Geometry"); 29 conf.CreateSection("Timing"); 30 conf.CreateSection("Behavior"); 31 conf.CreateSection("Filtering"); 32 conf.FlushFile(); 33 } 22 return; 34 23 35 24 char buf[MAX_LINE_LEN] = ""; 36 25 37 #define COPY(key, dst, def); \ 38 conf.ReadStr((key), buf, (def)); \ 26 #define SECT(name); \ 27 if (!conf.SetSection((name))) \ 28 conf.CreateSection((name)); \ 29 conf.SetSection((name)); 30 31 #define STR(key, dst, def); \ 32 if (!conf.ReadStr((key), buf, (def))) \ 33 conf.WriteStr((key), buf); \ 39 34 if (buf[0] != '\0') \ 40 35 { \ … … 43 38 } 44 39 45 if (conf.SetSection("Appearance")) 46 {47 COPY("Font", font, "");40 #define NUM(key, dst, def); \ 41 if (!conf.ReadNum((key), (dst), (def))) \ 42 conf.WriteNum((key), (dst)); 48 43 49 conf.ReadBool("MarkSecureMessages", markSecure, true); 44 #define BOOL(key, dst, def); \ 45 if (!conf.ReadBool((key), (dst), (def))) \ 46 conf.WriteBool((key), (dst)); 47 48 SECT("Appearance"); 49 50 STR("Font", font, ""); 51 BOOL("MarkSecureMessages", markSecure, true); 52 53 SECT("Colouring"); 54 55 STR("Background", backColor, ""); 56 STR("Message", textColor, "yellow"); 57 STR("Control", textControlColor, "gray"); 58 STR("Shadow", shadowColor, "black"); 59 NUM("BackOpacity", backOpacity, 0); 60 NUM("TextOpacity", textOpacity, 255); 61 NUM("ShadowOpacity", shadowOpacity, 255); 62 63 #define FIX(key, dst); \ 64 if ((dst) > 255) \ 65 { \ 66 (dst) %= 255; \ 67 conf.WriteNum((key), (dst)); \ 50 68 } 51 69 52 if (conf.SetSection("Colouring")) 53 { 54 COPY("Background", backColor, ""); 55 COPY("Message", textColor, "yellow"); 56 COPY("Control", textControlColor, "gray"); 57 COPY("Shadow", shadowColor, "black"); 70 FIX("BackOpacity", backOpacity); 71 FIX("TextOpacity", textOpacity); 72 FIX("ShadowOpacity", shadowOpacity); 73 #undef FIX 58 74 59 conf.ReadNum("BackOpacity", backOpacity, 0); 60 conf.ReadNum("TextOpacity", textOpacity, 255); 61 conf.ReadNum("ShadowOpacity", shadowOpacity, 255); 75 SECT("Geometry"); 62 76 63 if (backOpacity > 255) 64 backOpacity %= 255; 65 if (textOpacity > 255) 66 textOpacity %= 255; 67 if (shadowOpacity > 255) 68 shadowOpacity %= 255; 77 NUM("HPosition", reinterpret_cast<unsigned short&>(posHorizontal), 0); 78 NUM("VPosition", reinterpret_cast<unsigned short&>(posVertical), 0); 79 80 #define FIX(key, dst); \ 81 if ((dst) > COORDINATE_MAXIMUM) \ 82 { \ 83 (dst) = COORDINATE_MINIMUM; \ 84 conf.WriteNum((key), reinterpret_cast<unsigned short&>((dst))); \ 69 85 } 70 86 71 if (conf.SetSection("Geometry")) 72 { 73 conf.ReadNum("HPosition", reinterpret_cast<unsigned short&>(posHorizontal), 0); 74 conf.ReadNum("VPosition", reinterpret_cast<unsigned short&>(posVertical), 0); 87 FIX("HPosition", posHorizontal); 88 FIX("VPosition", posVertical); 89 #undef FIX 75 90 76 if (posHorizontal > COORDINATE_MAXIMUM) 77 posHorizontal = COORDINATE_MINIMUM; 78 if (posVertical > COORDINATE_MAXIMUM) 79 posVertical = COORDINATE_MINIMUM; 91 NUM("HOffset", offsetHorizontal, 0); 92 NUM("VOffset", offsetVertical, 0); 80 93 81 conf.ReadNum("HOffset", offsetHorizontal, 0);82 conf.ReadNum("VOffset", offsetVertical, 0);94 NUM("HMargin", marginHorizontal, 0); 95 NUM("VMargin", marginVertical, 0); 83 96 84 conf.ReadNum("HMargin", marginHorizontal, 0); 85 conf.ReadNum("VMargin", marginVertical, 0); 97 NUM("ShadowOffset", shadowOffset, 2); 98 NUM("Width", wrapWidth, 0); 99 NUM("Lines", maxLines, 0); 86 100 87 conf.ReadNum("ShadowOffset", shadowOffset, 2); 88 conf.ReadNum("Width", wrapWidth, 0); 89 conf.ReadNum("Lines", maxLines, 0); 101 SECT("Timing"); 102 103 NUM("FadeIn", fadeIn, 150); 104 NUM("FadeFull", fadeFull, 3000); 105 NUM("FadeOut", fadeOut, 150); 106 NUM("DelayPerCharacter", delayPerChar, 0); 107 108 SECT("Behavior"); 109 110 BOOL("Wait", wait, true); 111 BOOL("MouseActive", mouseActive, true); 112 NUM("QuietTimeout", quietTimeout, 0); 113 114 SECT("Filtering"); 115 116 NUM("ShowLogonLogoff", reinterpret_cast<unsigned short&>(logonLogoff), 2); 117 NUM("ShowStatusChange", reinterpret_cast<unsigned short&>(statusChange), 2); 118 NUM("ShowAutoResponseCheck", reinterpret_cast<unsigned short&>(autoResponse), 2); 119 NUM("ShowMessages", reinterpret_cast<unsigned short&>(showMessage), 2); 120 121 #define FIX(key, dst); \ 122 if ((dst) > GROUP_TYPE_ALL) \ 123 { \ 124 (dst) = GROUP_TYPE_ALL; \ 125 conf.WriteNum((key), reinterpret_cast<unsigned short&>((dst))); \ 90 126 } 91 127 92 if (conf.SetSection("Timing"))93 {94 conf.ReadNum("FadeIn", fadeIn, 150);95 conf.ReadNum("FadeFull", fadeFull, 3000);96 conf.ReadNum("FadeOut", fadeOut, 150); 128 FIX("ShowLogonLogoff", logonLogoff); 129 FIX("ShowStatusChange", statusChange); 130 FIX("ShowAutoResponseCheck", autoResponse); 131 FIX("ShowMessages", showMessage); 132 #undef FIX 97 133 98 conf.ReadNum("DelayPerCharacter", delayPerChar, 0); 99 } 134 BOOL("ShowMessagesNotification", notifyOnly, false); 135 STR("ShowInModes", ownerModes, ""); 136 STR("ShowMsgsInModes", ownerModesMsg, ""); 100 137 101 if (conf.SetSection("Behavior")) 102 { 103 conf.ReadBool("Wait", wait, true); 104 conf.ReadBool("MouseActive", mouseActive, true); 105 conf.ReadNum("QuietTimeout", quietTimeout, 0); 106 } 138 #undef STR 139 #undef NUM 140 #undef BOOL 141 #undef SECT 107 142 108 if (conf.SetSection("Filtering")) 109 { 110 conf.ReadNum("ShowLogonLogoff", 111 reinterpret_cast<unsigned short&>(logonLogoff), 2); 112 conf.ReadNum("ShowStatusChange", 113 reinterpret_cast<unsigned short&>(statusChange), 2); 114 conf.ReadNum("ShowAutoResponseCheck", 115 reinterpret_cast<unsigned short&>(autoResponse), 2); 116 conf.ReadNum("ShowMessages", 117 reinterpret_cast<unsigned short&>(showMessage), 2); 118 119 if (logonLogoff > GROUP_TYPE_ALL) 120 logonLogoff = GROUP_TYPE_ALL; 121 if (statusChange > GROUP_TYPE_ALL) 122 statusChange = GROUP_TYPE_ALL; 123 if (autoResponse > GROUP_TYPE_ALL) 124 autoResponse = GROUP_TYPE_ALL; 125 if (showMessage > GROUP_TYPE_ALL) 126 showMessage = GROUP_TYPE_ALL; 127 128 conf.ReadBool("ShowMessagesNotification", notifyOnly, false); 129 COPY("ShowInModes", ownerModes, ""); 130 COPY("ShowMsgsInModes", ownerModesMsg, ""); 131 } 132 133 #undef COPY 143 conf.FlushFile(); 134 144 } 135 145 -
branches/newosd/src/conf.h
r5984 r5987 17 17 ~Conf(); 18 18 19 void cleanup(); 19 20 void loadConfig(); 20 void cleanup();21 21 22 bool markSecure; 23 bool mouseActive; 24 bool notifyOnly; 25 bool wait; 26 27 char* backColor; 22 28 char* font; 29 char* ownerModes; 30 char* ownerModesMsg; 31 char* shadowColor; 32 char* textColor; 33 char* textControlColor; 23 34 24 35 AosdCoordinate posHorizontal; 25 36 AosdCoordinate posVertical; 37 26 38 short offsetHorizontal; 27 39 short offsetVertical; 40 short shadowOffset; 41 42 unsigned short backOpacity; 43 unsigned short delayPerChar; 44 unsigned short fadeFull; 45 unsigned short fadeIn; 46 unsigned short fadeOut; 28 47 unsigned short marginHorizontal; 29 48 unsigned short marginVertical; 30 short wrapWidth;31 49 unsigned short maxLines; 50 unsigned short quietTimeout; 51 unsigned short shadowOpacity; 52 unsigned short textOpacity; 53 unsigned short wrapWidth; 32 54 33 char* backColor; 34 unsigned short backOpacity; 35 36 char* shadowColor; 37 unsigned short shadowOpacity; 38 short shadowOffset; 39 40 char* textColor; 41 char* textControlColor; 42 unsigned short textOpacity; 43 44 bool markSecure; 45 46 unsigned short fadeIn; 47 unsigned short fadeFull; 48 unsigned short fadeOut; 49 unsigned short delayPerChar; 50 unsigned short quietTimeout; 51 52 bool wait; 53 bool mouseActive; 54 55 UserGroupType autoResponse; 55 56 UserGroupType logonLogoff; 57 UserGroupType showMessage; 56 58 UserGroupType statusChange; 57 UserGroupType autoResponse;58 UserGroupType showMessage;59 bool notifyOnly;60 char* ownerModes;61 char* ownerModesMsg;62 59 63 60 friend class Iface; -
branches/newosd/src/plugin.cpp
r5981 r5987 1 // -*- c-basic-offset: 2; -*-2 3 1 #include "config.h" 4 2
