| 60 | | setDefaults(); |
| 61 | | return; |
| 62 | | }*/ |
| | 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 | } |
| | 34 | |
| | 35 | char buf[MAX_LINE_LEN] = ""; |
| | 36 | |
| | 37 | #define COPY(key, dst, def); \ |
| | 38 | conf.ReadStr((key), buf, (def)); \ |
| | 39 | if (buf[0] != '\0') \ |
| | 40 | { \ |
| | 41 | (dst) = strdup(buf); \ |
| | 42 | buf[0] = '\0'; \ |
| | 43 | } |
| | 44 | |
| | 45 | if (conf.SetSection("Appearance")) |
| | 46 | { |
| | 47 | COPY("Font", font, ""); |
| | 48 | |
| | 49 | conf.ReadBool("MarkSecureMessages", markSecure, true); |
| | 50 | } |
| | 51 | |
| | 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"); |
| | 58 | |
| | 59 | conf.ReadNum("BackOpacity", backOpacity, 0); |
| | 60 | conf.ReadNum("TextOpacity", textOpacity, 255); |
| | 61 | conf.ReadNum("ShadowOpacity", shadowOpacity, 255); |
| | 62 | |
| | 63 | if (backOpacity > 255) |
| | 64 | backOpacity %= 255; |
| | 65 | if (textOpacity > 255) |
| | 66 | textOpacity %= 255; |
| | 67 | if (shadowOpacity > 255) |
| | 68 | shadowOpacity %= 255; |
| | 69 | } |
| | 70 | |
| | 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); |
| | 75 | |
| | 76 | if (posHorizontal > COORDINATE_MAXIMUM) |
| | 77 | posHorizontal = COORDINATE_MINIMUM; |
| | 78 | if (posVertical > COORDINATE_MAXIMUM) |
| | 79 | posVertical = COORDINATE_MINIMUM; |
| | 80 | |
| | 81 | conf.ReadNum("HOffset", offsetHorizontal, 0); |
| | 82 | conf.ReadNum("VOffset", offsetVertical, 0); |
| | 83 | |
| | 84 | conf.ReadNum("HMargin", marginHorizontal, 0); |
| | 85 | conf.ReadNum("VMargin", marginVertical, 0); |
| | 86 | |
| | 87 | conf.ReadNum("ShadowOffset", shadowOffset, 2); |
| | 88 | conf.ReadNum("Width", wrapWidth, 0); |
| | 89 | conf.ReadNum("Lines", maxLines, 0); |
| | 90 | } |
| | 91 | |
| | 92 | if (conf.SetSection("Timing")) |
| | 93 | { |
| | 94 | conf.ReadNum("FadeIn", fadeIn, 150); |
| | 95 | conf.ReadNum("FadeFull", fadeFull, 3000); |
| | 96 | conf.ReadNum("FadeOut", fadeOut, 150); |
| | 97 | |
| | 98 | conf.ReadNum("DelayPerCharacter", delayPerChar, 0); |
| | 99 | } |
| | 100 | |
| | 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 | } |
| | 107 | |
| | 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 |
| | 134 | } |
| | 135 | |
| | 136 | void Conf::cleanup() |
| | 137 | { |
| | 138 | #define CLEAN(str); \ |
| | 139 | if ((str) != NULL) \ |
| | 140 | { \ |
| | 141 | free((str)); \ |
| | 142 | (str) = NULL; \ |
| | 143 | } |
| | 144 | |
| | 145 | CLEAN(font); |
| | 146 | CLEAN(backColor); |
| | 147 | CLEAN(shadowColor); |
| | 148 | CLEAN(textColor); |
| | 149 | CLEAN(textControlColor); |
| | 150 | CLEAN(ownerModes); |
| | 151 | CLEAN(ownerModesMsg); |
| | 152 | #undef CLEAN |