Changeset 5981 for branches/newosd
- Timestamp:
- 01/03/08 00:56:18 (11 months ago)
- Location:
- branches/newosd/src
- Files:
-
- 2 added
- 4 modified
-
CMakeLists.txt (modified) (1 diff)
-
conf.cpp (added)
-
conf.h (added)
-
iface.cpp (modified) (8 diffs)
-
iface.h (modified) (2 diffs)
-
plugin.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/newosd/src/CMakeLists.txt
r5856 r5981 3 3 set(SRCS 4 4 plugin.cpp 5 conf.cpp 5 6 iface.cpp) 6 7 -
branches/newosd/src/iface.cpp
r5979 r5981 4 4 #include <licq_translate.h> 5 5 6 #include "conf.h" 7 6 8 Iface::Iface() 7 9 { 8 10 aosd = aosd_new(); 9 11 aosd_set_transparency(aosd, TRANSPARENCY_COMPOSITE); 10 aosd_set_hide_upon_mouse_event(aosd, True);11 12 aosd_set_renderer(aosd, aosd_text_renderer, &trd); 12 13 aosd_set_names(aosd, "OSD Plugin", "Licq"); 13 14 15 g_type_init(); 14 16 memset(&trd, 0, sizeof(TextRenderData)); 15 16 g_type_init();17 18 17 trd.lay = pango_layout_new_aosd(); 19 20 trd.geom.x_offset = 10;21 trd.geom.y_offset = 10;22 23 trd.shadow.x_offset = 2;24 trd.shadow.y_offset = 2;25 trd.shadow.color = "black";26 trd.shadow.opacity = 192;27 28 trd.fore.opacity = 255;29 30 pango_layout_set_font_aosd(trd.lay, "Times New Roman Bold 24");31 32 int max_width;33 aosd_get_screen_size(aosd, &max_width, NULL);34 max_width -= 2 * trd.geom.x_offset + trd.shadow.x_offset + 80;35 if (max_width > 0)36 pango_layout_set_width(trd.lay, max_width * PANGO_SCALE);37 18 pango_layout_set_wrap(trd.lay, PANGO_WRAP_WORD_CHAR); 19 20 conf = new Conf(); 21 22 updateTextRenderData(); 23 24 FOR_EACH_OWNER_START(LOCK_R) 25 { 26 ppidTimers[pOwner->PPID()] = time(NULL); 27 } 28 FOR_EACH_OWNER_END; 38 29 } 39 30 40 31 Iface::~Iface() 41 32 { 33 delete conf; 34 ppidTimers.clear(); 42 35 aosd_destroy(aosd); 43 36 pango_layout_unref_aosd(trd.lay); … … 47 40 { 48 41 string msg = ""; 49 bool message = false;42 bool control = true; 50 43 51 44 switch (sig->Signal()) … … 53 46 case SIGNAL_UPDATExUSER: 54 47 { 55 if (!checkDisabledTimer() || 56 !checkOwner(sig)) 48 if (filterSignal(sig)) 57 49 break; 58 50 59 ICQUser* u = checkUser(sig->Id(), sig->PPID());51 ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 60 52 if (u == NULL) 61 53 break; … … 86 78 87 79 { 88 CUserEvent* ue = u->EventPeekId(sig->Argument()); 89 if (ue == NULL) 90 break; 91 if (u->Secure()) // TODO config check 92 msg += " (S)"; 93 msg += ": "; 94 char* trans = gTranslator.ToUnicode(const_cast<char*>(ue->Text()), 95 u->UserEncoding()); 96 msg += trans; 97 delete[] trans; 98 message = true; 80 control = false; 81 if (conf->notifyOnly) 82 { 83 msg = "Message from "; 84 msg += u->GetAlias(); 85 if (conf->markSecure && u->Secure()) 86 msg += " [secured]"; 87 msg += "."; 88 } 89 else 90 { 91 CUserEvent* ue = u->EventPeekId(sig->Argument()); 92 if (ue == NULL) 93 break; 94 if (conf->markSecure && u->Secure()) 95 msg += " (S)"; 96 msg += ": "; 97 char* trans = gTranslator.ToUnicode(const_cast<char*>(ue->Text()), 98 u->UserEncoding()); 99 msg += trans; 100 delete[] trans; 101 } 99 102 } 100 103 break; … … 110 113 111 114 case SIGNAL_LOGON: 112 break;113 114 115 case SIGNAL_LOGOFF: 116 ppidTimers[sig->PPID()] = time(NULL) + conf->quietTimeout; 115 117 break; 116 118 … … 120 122 121 123 if (!msg.empty()) 122 displayLayout(msg, message); 123 } 124 125 ICQUser* Iface::checkUser(char* id, unsigned long ppid) 126 { 127 if (id == NULL) 128 return NULL; 129 130 ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_R); 131 124 displayLayout(msg, control); 125 } 126 127 void Iface::updateTextRenderData() 128 { 129 conf->loadConfig(); 130 131 aosd_set_hide_upon_mouse_event(aosd, conf->mouseActive); 132 pango_layout_set_font_aosd(trd.lay, conf->font); 133 134 trd.geom.x_offset = conf->marginHorizontal; 135 trd.geom.y_offset = conf->marginVertical; 136 137 trd.back.color = conf->backColor; 138 trd.back.opacity = conf->backOpacity; 139 140 trd.shadow.x_offset = conf->shadowOffset; 141 trd.shadow.y_offset = conf->shadowOffset; 142 trd.shadow.color = conf->shadowColor; 143 trd.shadow.opacity = conf->shadowOpacity; 144 145 trd.fore.opacity = conf->textOpacity; 146 147 int width = aosd_text_get_screen_wrap_width(aosd, &trd); 148 if (conf->wrapWidth == 0 || width < 0) 149 pango_layout_set_width(trd.lay, -1); 150 else 151 pango_layout_set_width(trd.lay, 152 (width > conf->wrapWidth ? conf->wrapWidth : width) * PANGO_SCALE); 153 } 154 155 bool Iface::filterSignal(CICQSignal* sig) 156 { 157 if (ppidTimers[sig->PPID()] > time(NULL)) 158 return true; 159 160 bool ret = false; 161 162 ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 132 163 if (u == NULL) 133 return NULL;164 return true; 134 165 135 166 if (u->IgnoreList()) 136 { 137 gUserManager.DropUser(u); 138 return NULL; 139 } 140 141 return u; 142 } 143 144 bool Iface::checkOwner(CICQSignal* sig) 145 { 167 ret = true; 168 169 gUserManager.DropUser(u); 170 171 if (ret) 172 return true; 173 146 174 ICQOwner* o = gUserManager.FetchOwner(sig->PPID(), LOCK_R); 147 148 175 if (o == NULL) 149 return false; 150 151 bool ret = true; 176 return true; 152 177 153 178 do … … 155 180 // TODO status check 156 181 182 // Don't let owner messages (e.g. auth-reqs) be filtered 157 183 if (sig->Signal() == SIGNAL_UPDATExUSER && 158 184 sig->SubSignal() == USER_EVENTS && … … 162 188 if (strcmp(sig->Id(), o->IdString()) == 0) 163 189 { 164 ret = false;190 ret = true; 165 191 break; 166 192 } 167 168 193 } while (false); 169 194 170 gUserManager.DropOwner(sig->PPID()); 195 gUserManager.DropOwner(o->PPID()); 196 171 197 return ret; 172 198 } 173 199 174 bool Iface::checkDisabledTimer() 175 { 176 return true; 177 } 178 179 void Iface::displayLayout(string& msg, bool message) 200 void Iface::displayLayout(string& msg, bool control) 180 201 { 181 202 pango_layout_set_text(trd.lay, const_cast<char*>(msg.c_str()), -1); 182 203 183 trd.fore.color = con st_cast<char*>(message ? "green" : "gray");204 trd.fore.color = control ? conf->textControlColor : conf->textColor; 184 205 185 206 unsigned width, height; 186 207 187 pango_layout_get_size_aosd(trd.lay, &width, &height, &trd.lbearing);208 aosd_text_get_size(&trd, &width, &height); 188 209 189 210 aosd_set_position_with_offset(aosd, 190 COORDINATE_MINIMUM, COORDINATE_MAXIMUM, 191 width + 2 * trd.geom.x_offset + trd.shadow.x_offset, 192 height + 2 * trd.geom.y_offset + trd.shadow.y_offset, 193 80, -80); 194 195 aosd_flash(aosd, 0, 3000, 150); 211 conf->posHorizontal, conf->posVertical, 212 width, height, conf->offsetHorizontal, conf->offsetVertical); 213 214 aosd_flash(aosd, conf->fadeIn, 215 conf->fadeFull + msg.size() * conf->delayPerChar, conf->fadeOut); 196 216 } 197 217 -
branches/newosd/src/iface.h
r5978 r5981 3 3 4 4 #include <string> 5 #include <map> 6 #include <time.h> 5 7 6 #include < libaosd/aosd.h>7 #include < libaosd/aosd-text.h>8 #include <aosd.h> 9 #include <aosd-text.h> 8 10 #undef Status 9 11 10 12 class CICQSignal; 11 13 class ICQUser; 14 15 class Conf; 12 16 13 17 class Iface … … 18 22 19 23 void processSignal(CICQSignal* sig); 24 void updateTextRenderData(); 20 25 21 26 private: 22 27 Aosd* aosd; 23 28 TextRenderData trd; 29 Conf* conf; 30 std::map<unsigned long, time_t> ppidTimers; 24 31 25 ICQUser* checkUser(char* id, unsigned long ppid); 26 bool checkOwner(CICQSignal* sig); 27 bool checkDisabledTimer(); 32 bool filterSignal(CICQSignal* sig); 28 33 29 const char* setLayoutTag(ICQUser* u); 30 void displayLayout(std::string& msg, bool message); 34 void displayLayout(std::string& msg, bool control); 31 35 }; 32 36 -
branches/newosd/src/plugin.cpp
r5980 r5981 108 108 109 109 case '1': 110 iface->updateTextRenderData(); 110 111 blocked = false; 111 112 break;
