core: move IM related code out of sipe.c