]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_safelist.cpp
Fix test client error cheecking on result types
[user/henk/code/inspircd.git] / src / modules / m_safelist.cpp
index e9ea965f93c52f10dd13554ef3c73582e035b6a0..148040c6c7e920d390800765367208b93f5d8fd5 100644 (file)
@@ -25,7 +25,7 @@ using namespace std;
  
 extern time_t TIME;
 
-class ListData
+class ListData : public classbase
 {
  public:
        long list_start;
@@ -76,11 +76,12 @@ class ListTimer : public InspTimer
                                 *  - If not, spool more channels
                                 */
                                userrec* u = (userrec*)(*iter);
-                               ListData* ld = (ListData*)u->GetExt("safelist_cache");
+                               ListData* ld;
+                               u->GetExt("safelist_cache", ld);
                                if (ld->list_position > Srv->GetChannelCount())
                                {
                                        u->Shrink("safelist_cache");
-                                       delete ld;
+                                       DELETE(ld);
                                        listusers.erase(iter);
                                        go_again = true;
                                        break;
@@ -165,7 +166,7 @@ class ModuleSafeList : public Module
         * OnPreCommand()
         *   Intercept the LIST command.
         */ 
-       virtual int OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
        {
                /* If the command doesnt appear to be valid, we dont want to mess with it. */
                if (!validated)
@@ -182,10 +183,11 @@ class ModuleSafeList : public Module
         * HandleList()
         *   Handle (override) the LIST command.
         */
-       int HandleList(char** parameters, int pcnt, userrec* user)
+       int HandleList(const char** parameters, int pcnt, userrec* user)
        {
                /* First, let's check if the user is currently /list'ing */
-               ListData *ld = (ListData*)user->GetExt("safelist_cache");
+               ListData *ld;
+               user->GetExt("safelist_cache", ld);
  
                if (ld)
                {
@@ -193,7 +195,8 @@ class ModuleSafeList : public Module
                        return 1;
                }
 
-               time_t* last_list_time = (time_t*)user->GetExt("safelist_last");
+               time_t* last_list_time;
+               user->GetExt("safelist_last", last_list_time);
                if (last_list_time)
                {
                        if (TIME < (*last_list_time)+60)
@@ -202,7 +205,7 @@ class ModuleSafeList : public Module
                                return 1;
                        }
 
-                       delete last_list_time;
+                       DELETE(last_list_time);
                        user->Shrink("safelist_last");
                }
  
@@ -210,12 +213,12 @@ class ModuleSafeList : public Module
                 * start at channel 0! ;)
                 */
                ld = new ListData(0,TIME);
-               user->Extend("safelist_cache", (char*)ld);
+               user->Extend("safelist_cache", ld);
                listusers.push_back(user);
 
                time_t* llt = new time_t;
                *llt = TIME;
-               user->Extend("safelist_last",(char*)llt);
+               user->Extend("safelist_last", llt);
        
                return 1;
        }
@@ -225,11 +228,12 @@ class ModuleSafeList : public Module
                if(target_type == TYPE_USER)
                {
                        userrec* u = (userrec*)item;
-                       ListData* ld = (ListData*)u->GetExt("safelist_cache");
+                       ListData* ld;
+                       u->GetExt("safelist_cache", ld);
                        if (ld)
                        {
                                u->Shrink("safelist_cache");
-                               delete ld;
+                               DELETE(ld);
                        }
                        for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++)
                        {
@@ -240,10 +244,11 @@ class ModuleSafeList : public Module
                                        break;
                                }
                        }
-                       time_t* last_list_time = (time_t*)u->GetExt("safelist_last");
+                       time_t* last_list_time;
+                       u->GetExt("safelist_last", last_list_time);
                        if (last_list_time)
                        {
-                               delete last_list_time;
+                               DELETE(last_list_time);
                                u->Shrink("safelist_last");
                        }
                }