Flushing permalinks when you enable a plugin is REALLY simple, it can be done with the following snippet. This snippet needs to be in the root file of your plugin, e.g. wp-content/plugins/plugin/plugin.php
function pluginActivated()
{
flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'pluginActivated');